summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-05-26 16:16:04 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-05-26 16:16:04 +0200
commit85821fde180fadbd2d5a1a5147fc38598ac9f390 (patch)
tree3b707b25d0aa142dfa69f661b1f2cc59677d884b
parent5561b3c4d3712e7ee187f4ee69ec1463b1d320d6 (diff)
downloadabrt-85821fde180fadbd2d5a1a5147fc38598ac9f390.tar.gz
abrt-85821fde180fadbd2d5a1a5147fc38598ac9f390.tar.xz
abrt-85821fde180fadbd2d5a1a5147fc38598ac9f390.zip
trivial: add xsete[gu]id to abrtlib
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--lib/Utils/xfuncs.cpp12
-rw-r--r--lib/Utils/xfuncs.h6
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp
index 89273675..e2f9b4d3 100644
--- a/lib/Utils/xfuncs.cpp
+++ b/lib/Utils/xfuncs.cpp
@@ -390,6 +390,18 @@ bool string_to_bool(const char *s)
return false;
}
+void xseteuid(uid_t euid)
+{
+ if (seteuid(euid) != 0)
+ perror_msg_and_die("can't set %cid %lu", 'u', (long)euid);
+}
+
+void xsetegid(gid_t egid)
+{
+ if (setegid(egid) != 0)
+ perror_msg_and_die("can't set %cid %lu", 'g', (long)egid);
+}
+
void xsetreuid(uid_t ruid, uid_t euid)
{
if (setreuid(ruid, euid) != 0)
diff --git a/lib/Utils/xfuncs.h b/lib/Utils/xfuncs.h
index 93baa175..de785c8e 100644
--- a/lib/Utils/xfuncs.h
+++ b/lib/Utils/xfuncs.h
@@ -76,12 +76,12 @@ extern char *last_char_is(const char *s, int c);
extern bool string_to_bool(const char *s);
+extern void xseteuid(uid_t euid);
+extern void xsetegid(gid_t egid);
extern void xsetreuid(uid_t ruid, uid_t euid);
extern void xsetregid(gid_t rgid, gid_t egid);
-/* Do not pass the returned pointer to free().
- Do not modify the contents of the returned string.
- NULL is returned in the case of failure. */
+/* Returns getpwuid(uid)->pw_dir or NULL */
extern const char *get_home_dir(uid_t uid);
#ifdef __cplusplus