Re: shell script how to switch users?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
Thanks a lot for your quick responses.  After executing su - user2 -c
script . I am asked for password for user2. Is there any way through
we can we specify password too with this command.
- Rajiv

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list


As Mike suggests, you can use sudo.  Then with the option -S to
specify that the password will come from standard input instead of tty
(and then feed it using the < redirect), and the -u user2 to specify
to sudo to user2 instead of to root.  The security vulnerability being
that your password will have to come from somewhere (either within the
script or redirected from within a text file containing the password)
readable. Meaning someone who disects the script can figure out where
to go find the password (if it's not in the script).

There may be a way to do this a bit more securely, but I am not
certain.  I gather the script will run unattended, or will be run by
someone who should not know the password for user2?  If user1 is any
bit curious, he/she will be able to find out the password for user2
quite easily  by examing the script.  Unfortunately the script won't
run without r permission in addition to x permission (I tried with x
but no r and the script will not run).

Jacques B.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux