Results 1 to 9 of 9

Thread: Suid root seems not to work - Getting SUIDcidal ;-)

  1. #1
    Junior Member
    Join Date
    Jul 2005
    Posts
    2

    Suid root seems not to work - Getting SUIDcidal ;-)

    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:

    Code:
    crw-rw-rw-  1 root root 99, 0 Feb  9 19:40 /dev/parport0
    The program has been compiled using gcc -O1 -o test test.c, after which I've issued (as root):

    Code:
    chown root:users test
    chmod u+s test
    I figured it should work now, but it doesn't. Keeps complaining about permissions.

    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:

    Code:
    chown root:users bar.sh
    chmod u+s bar.sh
    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.

    Thanks in advance,

    Marc.

  2. #2
    Junior Member
    Join Date
    Jul 2005
    Posts
    2

    Solved - sort of

    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?

  3. #3
    Senior Member registered user
    Join Date
    Nov 2002
    Location
    USA, IL
    Posts
    1,041

    Re: Solved - sort of

    That's weird, man.

    Quote Originally Posted by mvandoornik
    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?

  4. #4
    Senior Member registered user
    Join Date
    Aug 2003
    Posts
    126
    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 by
    Code:
    $PATH
    followed by <enter> at a terminal window. Do this for root and for a normal user and see if this helps explain what has happened.

  5. #5
    Senior Member registered user
    Join Date
    Nov 2002
    Location
    USA, IL
    Posts
    1,041
    I think you meant:
    echo $PATH

    Quote Originally Posted by markpreston
    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 by
    Code:
    $PATH
    followed by <enter> at a terminal window. Do this for root and for a normal user and see if this helps explain what has happened.

  6. #6
    Senior Member registered user
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    100
    > 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.

  7. #7
    Senior Member registered user
    Join Date
    Aug 2003
    Posts
    126
    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

  8. #8
    Senior Member registered user
    Join Date
    Nov 2002
    Location
    USA, IL
    Posts
    1,041
    --Yes, but it's not proper *nix form to try and _execute_ your PATH variable. Somebody could attack you that way.

    Quote Originally Posted by markpreston
    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

  9. #9
    Senior Member registered user
    Join Date
    Aug 2003
    Posts
    126
    Quote Originally Posted by Dave_Bechtel
    --Yes, but it's not proper *nix form to try and _execute_ your PATH variable. Somebody could attack you that way.
    Thanks Dave,
    At least I now know what you were concerned about.
    Regards,
    Mark

Similar Threads

  1. GUI Config editors not work as root.
    By pterandon in forum General Support
    Replies: 0
    Last Post: 06-04-2006, 03:41 AM
  2. Help - root-shell and su and sudo command do not work
    By GameMage in forum General Support
    Replies: 2
    Last Post: 11-12-2005, 06:44 AM
  3. KDE sys notification sounds work in root but not in user
    By lestat730 in forum Hdd Install / Debian / Apt
    Replies: 8
    Last Post: 01-20-2005, 07:05 AM
  4. language settings work only for root for some applications
    By jackren in forum Hdd Install / Debian / Apt
    Replies: 0
    Last Post: 08-29-2003, 01:02 PM
  5. Replies: 6
    Last Post: 01-27-2003, 05:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Dell PowerEdge R240 Intel Xeon E-2144G 3.6GHz 16GB DDR4 ECC NO HDD 250W picture

Dell PowerEdge R240 Intel Xeon E-2144G 3.6GHz 16GB DDR4 ECC NO HDD 250W

$149.00



VMware vCenter Server 8 STANDARD Perpetual License Key VC-STD-C (Legacy Pack) picture

VMware vCenter Server 8 STANDARD Perpetual License Key VC-STD-C (Legacy Pack)

$1599.95



Dell EMC PowerEdge R440 Xeon silver 4215 2.5GHz 16 GB ram  2x 550W PSU No HDD picture

Dell EMC PowerEdge R440 Xeon silver 4215 2.5GHz 16 GB ram 2x 550W PSU No HDD

$275.00



Dell EMC VxRail E560F 10-SFF 2*Gold 6230R 2.1GHz No RAM HBA330 iDrac Ent Server picture

Dell EMC VxRail E560F 10-SFF 2*Gold 6230R 2.1GHz No RAM HBA330 iDrac Ent Server

$349.99



Dell EMC PowerEdge R740 8 Bay Server w/ 32GB RAM 2x GOLD 6132 2x 1600W PSU H730p picture

Dell EMC PowerEdge R740 8 Bay Server w/ 32GB RAM 2x GOLD 6132 2x 1600W PSU H730p

$499.88



Dell PowerEdge C4130 1U AI GPU Server | 2x E5-2680 v3 | 32gb Ram | 2x 1600W picture

Dell PowerEdge C4130 1U AI GPU Server | 2x E5-2680 v3 | 32gb Ram | 2x 1600W

$409.99



Dell Poweredge R730xd 12LFF 2*2660v4 4*1Gbe h730 2x 750W Server CTO picture

Dell Poweredge R730xd 12LFF 2*2660v4 4*1Gbe h730 2x 750W Server CTO

$308.00



Dell PowerEdge R730XD 28 Core Server 2X Xeon E5-2680 V4 H730 32GB RAM No HDD picture

Dell PowerEdge R730XD 28 Core Server 2X Xeon E5-2680 V4 H730 32GB RAM No HDD

$381.93



Dell Intel X710-DA2 5N7Y5 Dual-Port 10GbE SFP+ PCIe 3.0 x8 Network Adapter picture

Dell Intel X710-DA2 5N7Y5 Dual-Port 10GbE SFP+ PCIe 3.0 x8 Network Adapter

$27.50



USB 2.0 Network Print Server LAN Print Share Server USB Wireless Print Server picture

USB 2.0 Network Print Server LAN Print Share Server USB Wireless Print Server

$25.19