0

I thought, that the service files under /lib/systemd/system/ determine as what user a service is started. But apparently that's not (always) the case. Here's an example:

~# ps faux
...
whoopsie  1445  0.0  0.1 388420 12604 ?        Ssl  08:22   0:00 /usr/bin/whoopsie -f
...

From the above output we see, that the process 'whoopsie' runs under the user 'whoopsie'

Now we look at the startupscript:

~# cat /lib/systemd/system/whoopsie.service

Description=crash report submission daemon
After=network-online.target
Wants=network-online.target

[Service]
Environment="CRASH_DB_URL=https://daisy.ubuntu.com"
ExecStart=/usr/bin/whoopsie -f
Restart=always

[Install]
WantedBy=multi-user.target

In that startup script is no user defined.

So what determines as which user a process is started?

geets
  • 35
  • 6

3 Answers3

3

While your observation is correct, it is not due to systemd. Whoopsie is run as root and simply drops its privileges.

fuero
  • 9,591
  • 1
  • 35
  • 40
2

Additional info, this whoopsie process changes userid from root to whoopsie after started.

Source code:

/* Drop privileges */
if (setgroups (1, &pw->pw_gid) < 0 ||
    setresgid (pw->pw_gid, pw->pw_gid, pw->pw_gid) < 0 ||
    setresuid (pw->pw_uid, pw->pw_uid, pw->pw_uid) < 0) {
    g_set_error (error, g_quark_from_static_string ("whoopsie-quark"), 0,
                 "Failed to become user: %s", username);
    return;
}

From: https://github.com/pexip/os-whoopsie-daisy/blob/master/src/whoopsie.c#L838

setresuid is the function to change user

Reference: http://man7.org/linux/man-pages/man2/setresuid.2.html

melvinto
  • 136
  • 1
  • Thanks, (without being a C-Programmer) I think that's the reason the that process runs with a certain user. So we can record: a linux processes user can be (and is often) determined by the sourcecode of that process. In other cases it's determined by the user who calls it or the configuration in the startup script – geets Apr 03 '20 at 06:41
1

Please refer user or group if nothing is specified some defaults are applicable. The default is "root".

asktyagi
  • 2,860
  • 2
  • 8
  • 25