diff --git a/tcl/tcl_directory.c b/tcl/tcl_directory.c index deb9e7a0d1..1ae9687cf4 100644 --- a/tcl/tcl_directory.c +++ b/tcl/tcl_directory.c @@ -81,6 +81,9 @@ static char *mds_owner( /* Return: ptr to "user" string #endif #ifdef HAVE_GETPWUID struct passwd *p = getpwuid(uid); + if (!p) { + p = getpwuid(owner); + } if (p) { username = alloca(strlen(p->pw_name) + 3); diff --git a/treeshr/TreePutRecord.c b/treeshr/TreePutRecord.c index 44cb67fb26..a1b24d3018 100644 --- a/treeshr/TreePutRecord.c +++ b/treeshr/TreePutRecord.c @@ -127,7 +127,11 @@ int _TreePutRecord(void *dbid, int nid, struct descriptor *descriptor_ptr, int compress_utility = utility_update == 2; #ifndef _WIN32 if (!saved_uic) - saved_uic = (getgid() << 16) | getuid(); + { + saved_uic = getuid(); + if (!(saved_uic & 0xFFFF0000)) + saved_uic = (getgid() << 16) | (saved_uic); + } #endif if (!(IS_OPEN(dblist))) return TreeNOT_OPEN; diff --git a/treeshr/TreeSegments.c b/treeshr/TreeSegments.c index 712a704a13..4c3cef6669 100644 --- a/treeshr/TreeSegments.c +++ b/treeshr/TreeSegments.c @@ -985,7 +985,14 @@ inline static int begin_finish(vars_t *vars) #ifndef _WIN32 static int saved_uic = 0; -static void init_saved_uic() { saved_uic = (getgid() << 16) | getuid(); } +static void init_saved_uic() { + if (!saved_uic) + { + saved_uic = getuid(); + if (!(saved_uic & 0xFFFF0000)) + saved_uic = (getgid() << 16) | (saved_uic); + } +} #endif inline static void begin_local_nci(vars_t *vars, const mdsdsc_a_t *initialValue)