diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-04-23 16:14:57 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-04-23 23:22:37 +0200 |
commit | 7bdbafc261f807b68fd5622500c70bbf363ae7c0 (patch) | |
tree | 0274bf6c5058eb6f1c3de6f46d81466b655888cb /src/basic/user-util.c | |
parent | ea086f0610030b12a04baee2b88fd81b661610b1 (diff) | |
download | systemd-7bdbafc261f807b68fd5622500c70bbf363ae7c0.tar.gz |
homectl: don't use password cache if we operate on other user
Diffstat (limited to 'src/basic/user-util.c')
-rw-r--r-- | src/basic/user-util.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/basic/user-util.c b/src/basic/user-util.c index 0ea4e409fa..3756e80c30 100644 --- a/src/basic/user-util.c +++ b/src/basic/user-util.c @@ -1072,3 +1072,16 @@ int fgetsgent_sane(FILE *stream, struct sgrp **sg) { return !!s; } #endif + +int is_this_me(const char *username) { + uid_t uid; + int r; + + /* Checks if the specified username is our current one. Passed string might be a UID or a user name. */ + + r = get_user_creds(&username, &uid, NULL, NULL, NULL, USER_CREDS_ALLOW_MISSING); + if (r < 0) + return r; + + return uid == getuid(); +} |