diff --git a/lib/error_numbers.h b/lib/error_numbers.h index 87b01467a5..b36b4f997a 100755 --- a/lib/error_numbers.h +++ b/lib/error_numbers.h @@ -168,7 +168,7 @@ #define ERR_WRONG_URL -219 #define ERR_DUP_NAME -220 #define ERR_ABORTED_BY_PROJECT -221 - +#define ERR_GETGRNAM -222 // PLEASE: add a text description of your error to // the text description function boincerror() in util.C. diff --git a/lib/util.C b/lib/util.C index e6f113b379..9bbdadddd9 100755 --- a/lib/util.C +++ b/lib/util.C @@ -40,6 +40,7 @@ #include #include #include +#include #ifdef HAVE_SYS_TIME_H #include #endif @@ -1023,6 +1024,7 @@ const char* boincerror(int which_error) { case ERR_FSYNC: return "Couldn't sync file"; case ERR_TRUNCATE: return "Couldn't truncate file"; case ERR_ABORTED_BY_PROJECT: return "Aborted by project"; + case ERR_GETGRNAM: return "Group not found"; case 404: return "HTTP file not found"; case 407: return "HTTP proxy authentication failure"; case 416: return "HTTP range request error"; @@ -1037,4 +1039,13 @@ const char* boincerror(int which_error) { return buf; } +#ifndef _WIN32 +int lookup_group(char* name, gid_t& gid) { + struct group* gp = getgrnam(name); + if (!gp) return ERR_GETGRNAM; + gid = gp->gr_gid; + return 0; +} +#endif + const char *BOINC_RCSID_ab65c90e1e = "$Id$"; diff --git a/lib/util.h b/lib/util.h index 56c1322689..5d307b4668 100755 --- a/lib/util.h +++ b/lib/util.h @@ -130,4 +130,8 @@ extern void mysql_timestamp(double, char*); // extern const char* boincerror(int which_error); +#ifndef _WIN32 +extern int lookup_group(char*, gid_t& gid); +#endif + #endif