How do i change to super user then revert back to ordinary user ,using shell script?
Solaris / OpenSolarisThis forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How do i change to super user then revert back to ordinary user ,using shell script?
Hi all,
I am trying to eject the cdrom from a livecd after certain stage...
Now assuming that it is possible to eject,please consider my issue!!!
The OS boots into a regular user by default...so i am unable to use the eject command to push out the drive...
However if i try pfexec eject it works....but then again it works only when the system is completely up and running not at some intermittent stage in the boot process.
How do i change the my id to a Superuser then execute the eject command ,then once the eject is done with, i would like to revert back to the ordinary user?
Secondly this code should be incorporated into one of the boot scripts,
So that after a certain stage during the boot, the drive automatically ejects......
How do i do it.....
PS:i urge you to consider that ejecting the media on a livecd is possible.
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
I understand the live-cd is copied on RAM to allow ejection when done. How would the OS survive an ejection if it is depending on the live-cd media content at an earlier stage ?
What is the issue with pfexec ? It is the preferred way to run privileged commands as a regular user under Solaris.
oh, so you want it out of me anyhow...
i have made this possible ...
The copy is done at an earlier stage itself...
Its not goin to wait till the gui is up for the copy to happen....
its now a part of the boot process ,meaning at a very primitive stage in the boot process itself the required files are copied to ram then on the cd becomes redundant....the remaining boot process including getting the gui will be done from ram
The pfexec program is used to execute commands with the
attributes specified by the user's profiles in the exec_attr file...
i want the cdrom to be ejected after all files have been copied on RAM and at the point whrer the boot process begins from ram....
I have located the scripts that run after the copy is done, and i am incorporating this script in that file...
I really dont mind if the ejection happens as soon as the copy is done or when the gui is up...I just want it to happen ,thats all.
This is what i do,
Code:
echo "changing user, and ejecting " >/dev/msglog
exec su - root -c eject 2>/dev/msglog &
rpid=$!
wait $rpid
if [ $? -eq 0 ];then
echo "how was it??" >/dev/msglog
else
echo "unlucky soul" >/dev/msglog
fi
The strange thing is ,if i make a script out of it,and then execute it as an ordinary user...(once the gui is up)it works flawlessly,
There is a momentary change in the user and then the eject happens , then i am taken back to ord user...
But if i try using this in the boot script i get no errors but still the ejection wont happen??
If its easier to perform this action once the gui is up, am ready to give that a try as well...
Could you please specify as to,howi can do it?
I am trying to eject the cdrom from a livecd after certain stage...
Now assuming that it is possible to eject,please consider my issue!!!
The OS boots into a regular user by default...so i am unable to use the eject command to push out the drive...
However if i try pfexec eject it works....but then again it works only when the system is completely up and running not at some intermittent stage in the boot process.
How do i change the my id to a Superuser then execute the eject command ,then once the eject is done with, i would like to revert back to the ordinary user?
Secondly this code should be incorporated into one of the boot scripts,
So that after a certain stage during the boot, the drive automatically ejects......
How do i do it.....
PS:i urge you to consider that ejecting the media on a livecd is possible.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.