+#if HAVE_ISSETUGID
+#define is_elevated() issetugid()
+#elif HAVE_GETEUID && HAVE_GETEGID
+#define is_elevated() \
+ (getuid() != geteuid() \
+ || getgid() != getegid())
+#else
+#define is_elevated() FALSE
+#endif
+
+#if HAVE_SETFSUID
+#define lower_privileges() \
+ int save_err = errno; \
+ setfsuid(getuid()); \
+ setfsgid(getgid()); \
+ errno = save_err
+#define resume_elevation() \
+ save_err = errno; \
+ setfsuid(geteuid()); \
+ setfsgid(getegid()); \
+ errno = save_err
+#else
+#define lower_privileges() /* nothing */
+#define resume_elevation() /* nothing */
+#endif
+