]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- show id of user if namename cannot be detected
authorArvin Schnell <aschnell@suse.de>
Fri, 1 Aug 2014 07:51:58 +0000 (09:51 +0200)
committerArvin Schnell <aschnell@suse.de>
Fri, 1 Aug 2014 07:51:58 +0000 (09:51 +0200)
client/misc.cc
client/misc.h
package/snapper.changes
snapper/AppUtil.cc
snapper/AppUtil.h

index c4b043b8a36577e5c0d56e9174e96fcbbed4e5a4..1d40ad7705e56f82c67d02996260a923b90bfdcb 100644 (file)
@@ -196,3 +196,16 @@ read_configdata(const list<string>& l, const map<string, string>& old)
 
     return configdata;
 }
+
+
+string
+username(uid_t uid)
+{
+    string username;
+    gid_t gid;
+
+    if (!get_uid_username_gid(uid, username, gid))
+       return sformat("unknown (%d)", uid);
+
+    return username;
+}
index 924a41fbfbf18997800685f35d4d1ab1de474198..65728ef46c97191b26d0a069155abc67234aea09 100644 (file)
@@ -47,3 +47,5 @@ show_userdata(const map<string, string>& userdata);
 map<string, string>
 read_configdata(const list<string>& l, const map<string, string>& old = map<string, string>());
 
+string
+username(uid_t uid);
index 08af4cd7be79e34cd6e3296e07f3d6430e77aee8..887d04b183191b036c19ba44022c27dedb28fe2c 100644 (file)
@@ -3,6 +3,7 @@ Thu Jul 31 15:38:16 CEST 2014 - aschnell@suse.de
 
 - also handle primary group of user when checking permissions
   (see gh#openSUSE/snapper#100)
+- show id of user if namename cannot be detected
 
 -------------------------------------------------------------------
 Fri Jul 25 12:38:33 CEST 2014 - aschnell@suse.de
index 681f332bac8168ccd32281de89808b75ab1c3b88..377ca8f823868d838e6dc234cffe8fed95b6ffb8 100644 (file)
@@ -262,24 +262,6 @@ namespace snapper
     }
 
 
-    string
-    username(uid_t uid)
-    {
-       struct passwd pwd;
-       struct passwd* result;
-
-       long bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
-       char buf[bufsize];
-
-       if (getpwuid_r(uid, &pwd, buf, bufsize, &result) != 0 || result != &pwd)
-           return "unknown";
-
-       memset(pwd.pw_passwd, 0, strlen(pwd.pw_passwd));
-
-       return pwd.pw_name;
-    }
-
-
     bool
     get_uid_username_gid(uid_t uid, string& username, gid_t& gid)
     {
index 1afb9c94fcb6bd233f3ed4b78540c5ea283edc94..452b48e111bbe5de11b49772a4fdb5f52ac8e93b 100644 (file)
@@ -85,7 +85,6 @@ namespace snapper
     string datetime(time_t time, bool utc, bool classic);
     time_t scan_datetime(const string& str, bool utc);
 
-    string username(uid_t uid);
     bool get_uid_username_gid(uid_t uid, string& username, gid_t& gid);
     bool get_user_uid(const char* username, uid_t& uid);
     bool get_group_gid(const char* groupname, gid_t& gid);