Find the answer to your Linux question:
Results 1 to 5 of 5
I'm a New Linux User and I wanna Know How to login as SU on Script I Mean wanna Design a Script but some commands on it Need the SU ...
  1. #1
    Just Joined!
    Join Date
    Nov 2010
    Posts
    3

    Question How to login as SU on Script

    I'm a New Linux User and I wanna Know
    How to login as SU on Script

    I Mean wanna Design a Script but some commands on it Need the SU Privilege How Can I do it
    Last edited by MikeTbob; 01-09-2011 at 01:56 PM. Reason: Changed font size

  2. #2
    Just Joined!
    Join Date
    Dec 2010
    Location
    India
    Posts
    45
    u can write a expect script in that case

  3. #3
    Just Joined!
    Join Date
    Nov 2010
    Posts
    3
    ok i'll give you an example
    if i wanna add a User to the system , I'll use adduser command
    but to use this command i must login as SU
    here what i wanna do
    i wanna run a script whose login as SU and do the Command

  4. #4
    Linux Newbie tetsujin's Avatar
    Join Date
    Oct 2008
    Posts
    115
    It is possible with certain tools like Perl to create an SUID script...

    SUID programs, in case you don't know, run as the user who owns the program file when they are executed:

    Code:
    $ ls -l /usr/bin/passwd
    -rwsr-xr-x 1 root root 41296 Jul 24  2009 /usr/bin/passwd
    Programs like "passwd" which need to perform privileged operations (read and write the shadow password file, in this case) must have the authority to do so. That is granted by the "suid" bit set on the program file. When you run /usr/bin/passwd, the "passwd" program gets root privileges.

    You can set the SUID bit on a script file - but Linux will not honor it. The reason for that is because it's highly dangerous. There are all kinds of ways you can subvert the operation of a script - exporting a different PATH or LD_PRELOAD variable, for instance - rather than allow people to compromise their systems with inherently dangerous SUID scripts, the decision was made to simply disable the feature.

    Perl works around this: if you have a Perl script that has the SUID bit set, the Perl interpreter will note this and attempt to run the script via the suid-perl mechanism. This enables some additional safety checks (input validation stuff, etc.) - so if you want to create an SUID utility but don't want to compile something, Perl is an option.

  5. #5
    Just Joined!
    Join Date
    Nov 2010
    Posts
    3
    thank you so much for your explication I'm So glade to Know you
    Last edited by Hamada_wolv; 01-12-2011 at 12:36 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
  •  
...