Could not get real user name + workaround
Hello!
Firstly, thank you so much for this proof-of-concept with systemd timers. Having an alarm ring only after I physically wake my pinephone was defeating the purpose of an alarm for me.
I ran into the "could not get real user name" error while using wake-mobile on my Manjaro+Phosh pinephone. getlogin()
seems to be returning NULL
in Manjaro ARM. I would have preferred to address the issue at the distro-level, but the getlogin()
manpage mysteriously explains that a NULL
is returned when the user's string "cannot be determined" =/
I worked around the issue with the following changes to set-user-alarm.c
:
#include <pwd.h>
...
// const char * const user = getlogin();
struct passwd * pwuser = getpwuid(getuid());
const char * const user = pwuser->pw_name;
if (user == NULL) {
...
I'm sure more can be done to check that getpwuid() doesn't return null as well, etc.
Wasn't sure if you wanted to take PRs/merge reqs for this, since upstream is already working on a different solution. But while the upstream process continues, your application works like a charm, and it solves a major problem with pinephone useability today. Thought I'd share, and thanks again for the simple but cool solution.