[systemd-devel] pam: Don't use loginuid [was: Re: Fix PAM module to not clobber XDG_RUNTIME_DIR with su]

Colin Guthrie gmane at colin.guthr.ie
Wed Nov 20 11:42:59 PST 2013


Hi,

Looks good generally but two very small points:


'Twas brillig, and Colin Walters at 20/11/13 17:34 did gyre and gimble:
> +/* Ensure the XDG_RUNTIME_DIR for root always exists, so that
> + * su/sudo/pkexec all do the right thing when changing to root.
> + */
> +static int ensure_root_runtime_path(void)
> +{
> +        struct passwd *pw;
> +        int r;
> +
> +        pw = getpwuid(0);
> +        if (!pw) {
> +                /* No root in passwd? Okay, we won't make a runtime
> +                 * directory now then, maybe it's some wacky network
> +                 * setup and it'll appear later.
> +                 */
> +                return 0;
> +        }
> +
> +        r = mkdir_safe_label("/run/user", 0755, 0, 0);
> +        if (r < 0) {
> +                log_error("Failed to create /run/user: %s", strerror(-r));
> +                return r;
> +        }
> +
> +        assert_se(pw->pw_uid == 0);


I see no side effect here... perhaps just use assert()? Also it would
feel better to go immediately after pw was populated rather than here
after the mkdir call, but maybe that's just me?

> +        r = mkdir_safe_label("/run/user/0", 0700, pw->pw_uid, pw->pw_gid);
> +        if (r < 0)
> +                return r;
> +        return 0;
> +}
> +
>  int main(int argc, char *argv[]) {
>          Manager *m = NULL;
>          int r;
> @@ -1172,12 +1203,15 @@ int main(int argc, char *argv[]) {
>          mkdir_label("/run/systemd/users", 0755);
>          mkdir_label("/run/systemd/sessions", 0755);
>  
> +        ensure_root_runtime_path();
> +
>          m = manager_new();
>          if (!m) {
>                  r = log_oom();
>                  goto finish;
>          }
>  
> +
>          manager_parse_config_file(m);

Trivial, but unneeded whitespace addition I think.

All the best


Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the systemd-devel mailing list