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
180 stars 16 forks source link

SUDO_USER is not defined #3

Closed boogerlad closed 9 years ago

boogerlad commented 9 years ago

If I'm running as root, USER gets assigned to SUDO_USER which is not defined. Then, I get Error: Cannot figure out who ran this script. Bailing out But root ran the script! What's the problem? Why can't we just always use the value of whoami?

graysky2 commented 9 years ago

Which terminal are you using?

boogerlad commented 9 years ago

I'm using terminator, but I'm getting this error with systemctl's timer on arch wiki.

graysky2 commented 9 years ago

I haven't tried using it with a systemctl timer running as root. I designed it to run as a normal user (ie cron). Can you set your timer to run as your user and see if that works?

boogerlad commented 9 years ago

uhoh I'm a bad person my user is root!

graysky2 commented 9 years ago

Please try version 2.27 with your systemd timer running as root. I am able to run as root with this code.

https://github.com/graysky2/modprobed-db/commit/d9ee195a724663e1cc9d15ab17095d9ca844667d

Note that I just released version 2.28 https://github.com/graysky2/modprobed-db/releases/tag/v2.28 which contains a proper timer/service. See the manpage.

boogerlad commented 9 years ago

Sorry I have been gone so long but I just tested this and it works perfectly now!!! Thank you!!

boogerlad commented 9 years ago

Hmm, I tried updating linux-ck with modprobed-db enabled in the pkgbuild and I got the "cannot determine your username so exiting" Inspecting the script, I see this

elif [[ "$SUDO_USER" = "root" ]]; then
  mesg="Cannot determine your username so exiting."
  echo -e "==> ERROR: ${mesg}" && exit 1

Is this an intentional thing to prevent running it as root?

However, systemctl status modprobed-db@root.service shows no errors...

graysky2 commented 9 years ago

So you set the service to your user, not root? The database should be in your homedir then. Is it?

boogerlad commented 9 years ago

My user is root. The service is set to root. I am updating the linux-ck package with yaourt as root as well. I'm not sure where the database is located since I am not with the computer with Arch atm.

graysky2 commented 9 years ago

Have to revisit this. I never intended users to run it as root but the database should be in /root/.config/modprobed.* if you're running it as root.

graysky2 commented 9 years ago

@boogerlad I cannot reproduce this. Even if I login as root I am able to store and recall as root without any errors. Can you confirm?

boogerlad commented 9 years ago

I can't reproduce either. Not enough time and no desktop. I will reopen when the time comes.