graysky2 / modprobed-db

Keeps track of EVERY kernel module that has ever been probed. Useful for those of us who make localmodconfig :)
https://wiki.archlinux.org/index.php/Modprobed-db
181 stars 16 forks source link

problems with su - #9

Closed mrVanDalo closed 9 years ago

mrVanDalo commented 9 years ago

I have problems using this script with su -

palo@iron [~]$ su - 
Password:
root@iron [~]# modprobed-db 
Modprobed-db v2.24

172 modules currently loaded per /proc/modules
172 modules are in /home/palo/.config/modprobed.db

/usr/bin/modprobed-db {list|recall|store|debug}
See manpage for additional details

You use logname to find out the username.

root@iron [~]# logname 
palo
root@iron [~]# echo $USER 
root

I think my personal user is safe but, it makes it harder (have to use a console) for me to look in the database my cronjob is creating (and to load when building a kernel).

graysky2 commented 9 years ago

I never intended for the script to run as the root user... When you su - and invoke modprobed-db your output suggests that it is reading the palo user database which I cannot reproduce on my system. On my system:

% su -
# modprobed-db           
Modprobed-db v2.33

129 modules currently loaded per /proc/modules
131 modules are in /root/.config/modprobed.db
...

EDIT: Ah, you are using a pretty old version. Can you try with 2.33

mrVanDalo commented 9 years ago

yeah that's true, the version is very, old. (I'm using funtoo, so I will have to update the ebuild my-self, 2.24 is the newest version), give me a sec

mrVanDalo commented 9 years ago

Hmm still that problem ? Looks like there is something wrong with my su

root@iron [~]# modprobed-db 
Modprobed-db v2.33

191 modules currently loaded per /proc/modules
199 modules are in /home/palo/.config/modprobed.db

/usr/bin/modprobed-db [option]
  list      Show all modules currently in the database.
  store     Store any new module(s) to the database.
  storesilent   Store any new module(s) to the database more quietly.
  debug     Diff loaded modules from the database (show what did not get loaded).
  recall    Modprobe to load all modules in the database. MUST be called from sudo!

See manpage for additional details
graysky2 commented 9 years ago

Very odd behavior... what shell are you using? Same from a tty (console) or from a xterm (graphical)? Again, on my box, it points to /root/.config/modprobed.db

mrVanDalo commented 9 years ago

Same on a tty, when I login as palo and use su -. But it is correct if I use login as root. I'm maybe not the only one with that problem http://community.hpe.com/t5/System-Administration/Wrong-user-logname/td-p/2792340 but it looks I don't have /etc/utmp or some thing, no idea about this. ----> reading.

graysky2 commented 9 years ago

Why are you interesting in running the tool as root? If you have your crontab (palo) run the in store mode it should be fine to recall your (palo) database when invoked as sudo modprobed-db r ... at least, that is how I designed it to work.

mrVanDalo commented 9 years ago

Ok, /var/run/utmp is the place where this stuff is saved.

Same problem for using sudo. I'm interested in what should be the proper behavior of logname.

palo@iron [mydistro-overlay]$ sudo modprobed-db 
Modprobed-db v2.33

191 modules currently loaded per /proc/modules
199 modules are in /home/palo/.config/modprobed.db

/usr/bin/modprobed-db [option]
  list      Show all modules currently in the database.
  store     Store any new module(s) to the database.
  storesilent   Store any new module(s) to the database more quietly.
  debug     Diff loaded modules from the database (show what did not get loaded).
  recall    Modprobe to load all modules in the database. MUST be called from sudo!

See manpage for additional details

I mean it's not a very big problem for me, I can live by having the db in my home folder, but one last question: "why don't u use whoami instead of logname in the script to find out $USER?"

I will find out what's the correct behavior of logname (according to sudo).

mrVanDalo commented 9 years ago

Here some shell output

palo@iron [mydistro-overlay]$ logname ; whoami ; echo $USER ; echo $LOGNAME
palo
palo
palo
palo
palo@iron [mydistro-overlay]$ su - 
Password: 
root@iron [~]# logname ; whoami ; echo $USER ; echo $LOGNAME
palo
root
root
root
mrVanDalo commented 9 years ago

http://stackoverflow.com/questions/4598001/how-do-you-find-the-original-user-through-multiple-sudo-and-su-commands

looks like logname should be used to find out the original username.

mrVanDalo commented 9 years ago

Anyway, you can close the ticket if you want. If you change it to make it run-able as root or not. As I wrote I'm fine with that stuff to be stored in my home folder.

Thanks for the quick response.

Cheers Ingolf

graysky2 commented 9 years ago

Yeah, I don't want to modify the behavior. Glad you got it working.