Browse Source

libgis: G_owner returns owner id

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54276 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 12 years ago
parent
commit
e5c82d3ac3
2 changed files with 7 additions and 56 deletions
  1. 1 1
      include/defs/gis.h
  2. 6 55
      lib/gis/paths.c

+ 1 - 1
include/defs/gis.h

@@ -493,7 +493,7 @@ char *G_convert_dirseps_to_host(char *);
 char *G_convert_dirseps_from_host(char *);
 int G_lstat(const char *, STRUCT_STAT *);
 int G_stat(const char *, STRUCT_STAT *);
-const char *G_owner(const char *);
+int G_owner(const char *);
 
 /* percent.c */
 void G_percent(long, long, int);

+ 6 - 55
lib/gis/paths.c

@@ -152,28 +152,24 @@ int G_lstat(const char *file_name, STRUCT_STAT *buf)
 }
 
 /**
- * \brief Get owner name of path
+ * \brief Get owner id of path
  *
  * Returns information about the specified file.
  *
  * \param path path to check
  *
- * \return Return owner name or anonymous
+ * \return Return owner id
  **/
 
-const char *G_owner(const char *path)
+int G_owner(const char *path)
 {
-    const char *name = NULL;
 
 #ifndef __MINGW32__
     STRUCT_STAT info;
-    struct passwd *p;
-    
+
     G_stat(path, &info);
-    p = getpwuid(info.st_uid);
-    if (p && p->pw_name && *p->pw_name)
-	name = G_store(p->pw_name);
 
+    return (int)info.st_uid;
 #else
 
     /* this code is taken from the official example to 
@@ -222,51 +218,6 @@ const char *G_owner(const char *path)
     }
     CloseHandle(hFile);
     
-    /* First call to LookupAccountSid to get the buffer sizes. */
-    bRtnBool = LookupAccountSid(
-		      NULL,			/* lpSystemName */
-		      pSidOwner,		/* lpSid */
-		      AcctName,			/* lpName */
-		      (LPDWORD)&dwAcctName,	/* cchName */
-		      DomainName,		/* lpReferencedDomainName */
-		      (LPDWORD)&dwDomainName,	/* cchReferencedDomainName */
-		      &eUse			/* peUse */
-		      );
-    
-    if (bRtnBool == FALSE)
-	G_fatal_error(_("Unable to look up account id"));
-
-
-    /* Reallocate memory for the buffers. */
-    AcctName = (LPTSTR)GlobalAlloc(GMEM_FIXED, dwAcctName);
-
-    if (AcctName == NULL) {
-	G_fatal_error(_("Unable to allocate memory for account name"));
-    }
-    
-    DomainName = (LPTSTR)GlobalAlloc(GMEM_FIXED, dwDomainName);
-
-    if (DomainName == NULL) {
-	G_fatal_error(_("Unable to allocate memory for domain name"));
-    }
-    
-    /* Second call to LookupAccountSid to get the account name. */
-    bRtnBool = LookupAccountSid(
-		      NULL,			/* lpSystemName */
-		      pSidOwner,		/* lpSid */
-		      AcctName,			/* lpName */
-		      (LPDWORD)&dwAcctName,	/* cchName */
-		      DomainName,		/* lpReferencedDomainName */
-		      (LPDWORD)&dwDomainName,	/* cchReferencedDomainName */
-		      &eUse			/* peUse */
-		      );
-    
-    if (bRtnBool == TRUE)
-	name = G_store(AcctName);
+    return (int)pSidOwner;
 #endif
-
-    if (!name || !*name)
-	name = "anonymous";
-
-    return name;
 }