[GRASS-SVN] r54276 - in grass/trunk: include/defs lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Dec 13 15:49:37 PST 2012


Author: mmetz
Date: 2012-12-13 15:49:37 -0800 (Thu, 13 Dec 2012)
New Revision: 54276

Modified:
   grass/trunk/include/defs/gis.h
   grass/trunk/lib/gis/paths.c
Log:
libgis: G_owner returns owner id

Modified: grass/trunk/include/defs/gis.h
===================================================================
--- grass/trunk/include/defs/gis.h	2012-12-13 23:44:52 UTC (rev 54275)
+++ grass/trunk/include/defs/gis.h	2012-12-13 23:49:37 UTC (rev 54276)
@@ -493,7 +493,7 @@
 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);

Modified: grass/trunk/lib/gis/paths.c
===================================================================
--- grass/trunk/lib/gis/paths.c	2012-12-13 23:44:52 UTC (rev 54275)
+++ grass/trunk/lib/gis/paths.c	2012-12-13 23:49:37 UTC (rev 54276)
@@ -152,28 +152,24 @@
 }
 
 /**
- * \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 @@
     }
     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;
 }



More information about the grass-commit mailing list