Am modifying a script I found for another distro(Ubuntu). It mostly works but some behaviors seem to be different on openSUSE.
Scenario:
The script has to be run with root permissions (su or sudo).
References in the script cd to the logged in User typically with something like the following
cd ~/directoryname
Problem:
Whereas on Ubuntu the above code sets the directory to the home directory of the logged in User, on openSUSE it instead sets to root’s home directory (because is running in the context of su or sudo).
Is there a simple solution?
Am considering stuff like declaring a variable with value of the current User’s directory, then cd to that.
Code you think should work appreciated.
An alternative I’ve considered is to simply place all directories which normally would be in the User’s home directory in root’s home directory instead.
Am modifying a script I found for another distro(Ubuntu). It mostly
works but some behaviors seem to be different on openSUSE.
Scenario:
The script has to be run with root permissions (su or sudo).
References in the script cd to the logged in User typically with
something like the following
Code:
cd ~/directoryname
Problem:
Whereas on Ubuntu the above code sets the directory to the home
directory of the logged in User, on openSUSE it instead sets to root’s
home directory (because is running in the context of su or sudo).
Is there a simple solution?
Am considering stuff like declaring a variable with value of the current
User’s directory, then cd to that.
Code you think should work appreciated.
An alternative I’ve considered is to simply place all directories which
normally would be in the User’s home directory in root’s home directory
instead.
TIA,
TSU
Hi
Allow the user to run the application by adding the user name and
application via visudo?
If running su and starts in the users home directory it should retain
the users env (add this your script to check/debug), else set the HOME
env variable.
–
Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
openSUSE 13.1 (Bottle) (x86_64) GNOME 3.10.2 Kernel 3.11.10-7-desktop
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!
> Whereas on Ubuntu the above code sets the directory to the home
> directory of the logged in User, on openSUSE it instead sets to root’s
> home directory (because is running in the context of su or sudo).
Telcontar:/home/cer # who am i
cer pts/12 2014-03-06 17:14 (:0)
Telcontar:/home/cer # exit
cer@Telcontar:~> su -
Password:
Telcontar:~ # who am i
cer pts/12 Mar 6 17:14 (:0)
Telcontar:~ #
You mean that?
–
Cheers / Saludos,
Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)
Thx for the suggestions,
but they don’t actually remedy the issue I described in my original post.
In the end, instead of trying to find a scripting solution that might not exist, I decided to “go with the flow of least resistance” (opt for the easiest available solution) and simply modify the script requirements to create objects and run in root’s home directory instead of the User root.
I for myself am very confused with your statement: “… run in root’s home directory instead of the User root”
Because doing things inside root’s home directory is only allowed to root owned processes (colloquialy called “being root”). Except of course when you have changed the permisions there, but I hope that such a break of security is at least reported here in the thread to make us understand what you are doing.
> Maybe we did not quite understand your question.
Same here.
> I for myself am very confused with your statement: “… run in root’s
> home directory instead of the User root”
>
> Because doing things inside root’s home directory is only allowed to
> root owned processes (colloquialy called “being root”). Except of course
> when you have changed the permisions there, but I hope that such a break
> of security is at least reported here in the thread to make us
> understand what you are doing.
If you do “su” or “sudo”, it is possible that things get written to the
home directory of the user that called su or sudo, but with root’s
attributes. However, if you do “su -”, they would go to “/root”.
Maybe he refers to that.
–
Cheers / Saludos,
Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)