tzplatform_get: fix to support numeric user id
[platform/core/system/tizen-platform-wrapper.git] / src / tzplatform_get.c
index f254f54..b37a5eb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Intel Corporation.
+ * Copyright (C) 2013-2014 Intel Corporation.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -57,7 +57,8 @@ int main(int argc, char **argv)
        int all = 0, not = 0, query = 0, export = 0, space = 0, list = 0, cont = 0;
        int i, n, *sel, p;
        enum tzplatform_variable id;
-       struct passwd *spw;
+       struct passwd pwd, *spw;
+       char buf[1024];
 
        /* parse args */
        while(*argv && **argv=='-') {
@@ -178,9 +179,9 @@ int main(int argc, char **argv)
        if (user) {
                for (i=0 ; '0' <= user[i] && user[i] <= '9' ; i++);
                if (user[i])
-                       spw = getpwnam(user);
+                       getpwnam_r(user, &pwd, buf, sizeof(buf), &spw);
                else
-                       spw = getpwuid((uid_t)atoi(user));
+                       getpwuid_r((uid_t)atoi(user), &pwd, buf, sizeof(buf), &spw);
                if (!spw) {
                        fprintf( stderr, "error! %s isn't standing for a valid user.\n", user);
                        if (!cont)