[libvirt] [PATCH] Add compat function for geteuid()

* configure.ac: Check for geteuid() * src/util/util.h: Compat for geteuid() --- configure.ac | 2 +- src/util/util.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index a58ee4e..e2b2b24 100644 --- a/configure.ac +++ b/configure.ac @@ -120,7 +120,7 @@ AC_MSG_RESULT([$have_cpuid]) dnl Availability of various common functions (non-fatal if missing), dnl and various less common threadsafe functions AC_CHECK_FUNCS_ONCE([cfmakeraw regexec sched_getaffinity getuid getgid \ - initgroups posix_fallocate mmap kill \ + geteuid initgroups posix_fallocate mmap kill \ getmntent_r getgrnam_r getpwuid_r]) dnl Availability of pthread functions (if missing, win32 threading is diff --git a/src/util/util.h b/src/util/util.h index 31c3a33..276e259 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -269,6 +269,10 @@ const char *virEnumToString(const char *const*types, static inline int getuid (void) { return 0; } # endif +# ifndef HAVE_GETUID +static inline int geteuid (void) { return 0; } +# endif + # ifndef HAVE_GETGID static inline int getgid (void) { return 0; } # endif -- 1.7.4

On 03/15/2011 06:32 AM, Daniel P. Berrange wrote:
* configure.ac: Check for geteuid() * src/util/util.h: Compat for geteuid() --- configure.ac | 2 +- src/util/util.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac index a58ee4e..e2b2b24 100644 --- a/configure.ac +++ b/configure.ac @@ -120,7 +120,7 @@ AC_MSG_RESULT([$have_cpuid]) dnl Availability of various common functions (non-fatal if missing), dnl and various less common threadsafe functions AC_CHECK_FUNCS_ONCE([cfmakeraw regexec sched_getaffinity getuid getgid \ - initgroups posix_fallocate mmap kill \ + geteuid initgroups posix_fallocate mmap kill \ getmntent_r getgrnam_r getpwuid_r])
ACK; and this is one that gnulib doesn't provide for us, so your implementation looks as good as any for mingw. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 03/15/2011 08:32 AM, Daniel P. Berrange wrote:
* configure.ac: Check for geteuid() * src/util/util.h: Compat for geteuid() --- configure.ac | 2 +- src/util/util.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac index a58ee4e..e2b2b24 100644 --- a/configure.ac +++ b/configure.ac @@ -120,7 +120,7 @@ AC_MSG_RESULT([$have_cpuid]) dnl Availability of various common functions (non-fatal if missing), dnl and various less common threadsafe functions AC_CHECK_FUNCS_ONCE([cfmakeraw regexec sched_getaffinity getuid getgid \ - initgroups posix_fallocate mmap kill \ + geteuid initgroups posix_fallocate mmap kill \ getmntent_r getgrnam_r getpwuid_r])
dnl Availability of pthread functions (if missing, win32 threading is diff --git a/src/util/util.h b/src/util/util.h index 31c3a33..276e259 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -269,6 +269,10 @@ const char *virEnumToString(const char *const*types, static inline int getuid (void) { return 0; } # endif
+# ifndef HAVE_GETUID
This should be HAVE_GETEUID, not HAVE_GETUID ;-)
+static inline int geteuid (void) { return 0; } +# endif + # ifndef HAVE_GETGID static inline int getgid (void) { return 0; } # endif
I wondered if gnulib had a replacement function for geteuid(), but it doesn't, so ACK after the small typo noted above is fixed.

On Tue, Mar 15, 2011 at 10:06:23AM -0400, Laine Stump wrote:
On 03/15/2011 08:32 AM, Daniel P. Berrange wrote:
* configure.ac: Check for geteuid() * src/util/util.h: Compat for geteuid() --- configure.ac | 2 +- src/util/util.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac index a58ee4e..e2b2b24 100644 --- a/configure.ac +++ b/configure.ac @@ -120,7 +120,7 @@ AC_MSG_RESULT([$have_cpuid]) dnl Availability of various common functions (non-fatal if missing), dnl and various less common threadsafe functions AC_CHECK_FUNCS_ONCE([cfmakeraw regexec sched_getaffinity getuid getgid \ - initgroups posix_fallocate mmap kill \ + geteuid initgroups posix_fallocate mmap kill \ getmntent_r getgrnam_r getpwuid_r])
dnl Availability of pthread functions (if missing, win32 threading is diff --git a/src/util/util.h b/src/util/util.h index 31c3a33..276e259 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -269,6 +269,10 @@ const char *virEnumToString(const char *const*types, static inline int getuid (void) { return 0; } # endif
+# ifndef HAVE_GETUID
This should be HAVE_GETEUID, not HAVE_GETUID ;-)
Yes, I'll push without the stupid typo ! Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Laine Stump