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

HPE Synergy 480 Gen10 Blade Server BAREBONES NO CPU, RAM OR HDD 🚚
$140.00
Dell PowerEdge M640 Blade Barebone Server Dell P/N: HHB006 Tested Working
$149.99
NETAPP HCI NAF-1701 SuperMicro Server 4X BLADE H410C 8X GOLD 5120 4 NODE SERVER
$1499.97
Dell PowerEdge M630 Blade Server 2x Xeon E5-2680 v4, 2F3MP , 4GDP5 ,R10KJ ,JVFVR
$96.60
Dell PowerEdge VRTX 2.5"x25 Bay Blade Enclosure 4x1600W + 4X M640 (4X Blades)
$1599.99
Dell PowerEdge FX2 FX2s Server 10GbE CMC Blade Enclosure Chassis
$274.99
Sealed HPE ProLiant BL460c Gen9 2x E5-2699v3 384GB 2x300GB 15K SAS 727021-B21
$2499.95
Dell PowerEdge M620 Blade Server 2x Xeon E5-2680v2 256GB DDR3 RAM NO HDD
$349.99
Supermicro 938-16 16-LFF MicroCloud SuperServer 5038MR-H8TRF *No Blade Servers*
$159.99
Dell Poweredge VRTX 25Bay 2.5" 2x PERC 8, 2xCMC, I/O 1GB Pass Through, 4x PS
$578.08