Well, that wasn't too hard. After putting my program in a directory in the path, all seems well. OTOH, it doesn't work when it's in a directory that only belongs to my personal path. Does it have to be in the root's path somewhere?
Greetings!
As I'm using Kanotix (which doesn't seem to have such an extensive forum) and it's based on Knoppix, I figure I'll post this question here.
For a program which will use the parallel port for digital I/O, I'm trying to get access to the port WITHOUT being root (no sudo, either). For this, I've compiled a simple program in C, but it keeps complaining it has no permissions to access the port (/dev/parport0). Port permissions are as follows:
The program has been compiled using gcc -O1 -o test test.c, after which I've issued (as root):Code:crw-rw-rw- 1 root root 99, 0 Feb 9 19:40 /dev/parport0
I figured it should work now, but it doesn't. Keeps complaining about permissions.Code:chown root:users test chmod u+s test
Furthermore I've tried creating a file foo.txt and done chmod 600 foo.txt. Then made an executable script bar.sh, which just cat's foo.txt. Then:
Executing bar.sh also gives permission errors. So in other words: what gives? I'm stumped, but I've probably misunderstood how suid root works. Any help would be greatly appreciated.Code:chown root:users bar.sh chmod u+s bar.sh
Thanks in advance,
Marc.
Well, that wasn't too hard. After putting my program in a directory in the path, all seems well. OTOH, it doesn't work when it's in a directory that only belongs to my personal path. Does it have to be in the root's path somewhere?
That's weird, man.
Originally Posted by mvandoornik
If Kanotix is similar Knoppix I guess the $PATH variable for root has a different (more restricted) set of paths to a normal user. This is partly for security.
This can be tested byfollowed by <enter> at a terminal window. Do this for root and for a normal user and see if this helps explain what has happened.Code:$PATH
I think you meant:
echo $PATH
Originally Posted by markpreston
> Executing bar.sh also gives permission errors.
The suid permission bit is ignored for scripts for security reasons. Suid for "true" executables only give the *effective* UID,
not the *real* UID. This can make a difference, e.g. as in cpio.
Hi Dave,
$PATH alone works as well for this.
mark@z:~$ $PATH
bash: /home/mark/.dist/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/games:.: No such file or directory
mark@z:~$
mark@z:~$ su
Password:
root@z:/home/mark# $PATH
bash: /sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/games: No such file or directory
root@z:/home/mark#
I think you meant:
echo $PATH
--Yes, but it's not proper *nix form to try and _execute_ your PATH variable. Somebody could attack you that way.
Originally Posted by markpreston
Thanks Dave,Originally Posted by Dave_Bechtel
At least I now know what you were concerned about.
Regards,
Mark

Seagate ST6000NM0115 6TB 256MB 7200RPM 3.5" SATA 6.0Gb/s Enterprise Hard Drive
$159.99
Western Digital HUS726T4TAL5204 4TB 7.2K SAS 12Gb/s 3.5" 512e HDD NetApp X375A
$84.00
HUS726060ALA640 HGST Ultrastar 6TB SATA 6Gbps 7.2K 3.5" Hard Drive OF21860
$129.99
Toshiba 1TB 2.5" SATA HDD MQ01ABD100V 5400RPM 9.5mm Laptop Internal Hard Drive
$51.99
Hitachi / HGST Travelstar HTS541010B7E610 1TB 2.5" SATA III HDD
$29.99
HGST HUS724040ALA640 4TB 7200 RPM SATA 3.5" Internal Desktop Drive 100% Health
$78.00
HITACHI ULTRASTAR 2TB 7.2K 6G 3.5INCH SATA HDD HUS724020ALA640 | TESTED WIPED
$34.95
HGST Ultrastar 2TB 3.5" Enterprise SATA 7200RPM Internal HDD HUS724020ALA640
$54.99
Sun Oracle 7357761 14TB 7.2K 3.5 12G SAS-3 HDD Hard Disc Drive w/ Coral Bracket
$249.99
HDD 3.5" SATA Hard Drive with Windows 10/Win 11 64x Installed Legacy
$35.00