summaryrefslogtreecommitdiffstats
path: root/source/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-12-22 21:44:04 +0000
committerJeremy Allison <jra@samba.org>1998-12-22 21:44:04 +0000
commitf0ac4d3961e10ed0ed9543e5cebad0d3019e44c8 (patch)
treebf7de64a45a508d6777a8f8b3770348d6462929e /source/lib
parent80810371e6ee2ed33cb22a3629373131e92a7ab4 (diff)
downloadsamba-f0ac4d3961e10ed0ed9543e5cebad0d3019e44c8.tar.gz
samba-f0ac4d3961e10ed0ed9543e5cebad0d3019e44c8.tar.xz
samba-f0ac4d3961e10ed0ed9543e5cebad0d3019e44c8.zip
Spelling mistake change due to very pick people (you know who you are :-).
Changed privilage to privilege. Also added set_real_uid() call to lib/util_sec.c. Removed last set[re]uid calls from quotas.c - all such calls now live only in lib/util_sec.c. Jeremy.
Diffstat (limited to 'source/lib')
-rw-r--r--source/lib/smbrun.c12
-rw-r--r--source/lib/util_sec.c55
2 files changed, 47 insertions, 20 deletions
diff --git a/source/lib/smbrun.c b/source/lib/smbrun.c
index ad262c775a8..f8eb9134aed 100644
--- a/source/lib/smbrun.c
+++ b/source/lib/smbrun.c
@@ -28,7 +28,7 @@ extern int DEBUGLEVEL;
/****************************************************************************
This is a utility function of smbrun(). It must be called only from
-the child as it may leave the caller in a privilaged state.
+the child as it may leave the caller in a privileged state.
****************************************************************************/
static BOOL setup_stdout_file(char *outfile,BOOL shared)
{
@@ -40,9 +40,9 @@ static BOOL setup_stdout_file(char *outfile,BOOL shared)
close(1);
if (shared) {
- /* become root - unprivilaged users can't delete these files */
- gain_root_privilage();
- gain_root_group_privilage();
+ /* become root - unprivileged users can't delete these files */
+ gain_root_privilege();
+ gain_root_group_privilege();
}
if(sys_stat(outfile, &st) == 0) {
@@ -136,14 +136,14 @@ int smbrun(char *cmd,char *outfile,BOOL shared)
exit(80);
}
- /* now completely lose our privilages. This is a fairly paranoid
+ /* now completely lose our privileges. This is a fairly paranoid
way of doing it, but it does work on all systems that I know of */
become_user_permanently(uid, gid);
if (getuid() != uid || geteuid() != uid ||
getgid() != gid || getegid() != gid) {
- /* we failed to lose our privilages - do not execute
+ /* we failed to lose our privileges - do not execute
the command */
exit(81); /* we can't print stuff at this stage,
instead use exit codes for debugging */
diff --git a/source/lib/util_sec.c b/source/lib/util_sec.c
index f31f4f08275..a5f07413900 100644
--- a/source/lib/util_sec.c
+++ b/source/lib/util_sec.c
@@ -21,10 +21,10 @@
#include "includes.h"
/****************************************************************************
- Gain root privilage before doing something.
+ Gain root privilege before doing something.
****************************************************************************/
-void gain_root_privilage(void)
+void gain_root_privilege(void)
{
#if defined(HAVE_SETRESUID) && defined(HAVE_SETRESGID)
@@ -56,7 +56,7 @@ void gain_root_privilage(void)
Ensure our real and effective groups are zero.
****************************************************************************/
-void gain_root_group_privilage(void)
+void gain_root_group_privilege(void)
{
#ifdef HAVE_SETRESGID
setresgid(0,0,0);
@@ -82,18 +82,19 @@ int set_effective_uid(uid_t uid)
return -1;
}
}
+ return 0;
#endif
#endif
#if defined(HAVE_SETRESUID)
- if (setresuid(-1,uid,-1) != 0)
+ return setresuid(-1,uid,-1);
#elif defined(HAVE_SETREUID) && !defined(HAVE_SETEUID)
- if(setreuid(-1,uid) != 0)
+ return setreuid(-1,uid);
#else
if ((seteuid(uid) != 0) && (setuid(uid) != 0))
-#endif
return -1;
return 0;
+#endif
}
/****************************************************************************
@@ -103,14 +104,40 @@ int set_effective_uid(uid_t uid)
int set_effective_gid(gid_t gid)
{
#if defined(HAVE_SETRESGID)
- if (setresgid(-1,gid,-1) != 0)
+ return setresgid(-1,gid,-1);
#elif defined(HAVE_SETREGID) && !defined(HAVE_SETEGID)
- if (setregid(-1,gid) != 0)
+ return setregid(-1,gid);
#else
if ((setegid(gid) != 0) && (setgid(gid) != 0))
-#endif
return -1;
return 0;
+#endif
+}
+
+/****************************************************************************
+ Set *only* the real uid.
+****************************************************************************/
+
+int set_real_uid(uid_t uid)
+{
+#if defined(HAVE_TRAPDOOR_UID)
+#if defined(HAVE_SETUIDX)
+ /* AIX3 has setuidx which is NOT a trapoor function (tridge) */
+ return setuidx(ID_REAL,uid);
+#endif
+#endif
+
+#if defined(HAVE_SETRESUID)
+ return setresuid(uid,-1,-1);
+#elif defined(HAVE_SETREUID) && !defined(HAVE_SETEUID)
+ return setreuid(uid,-1);
+#else
+ /*
+ * Without either setresuid or setreuid we cannot
+ * independently set the real uid.
+ */
+ return -1;
+#endif
}
/****************************************************************************
@@ -120,17 +147,17 @@ int set_effective_gid(gid_t gid)
BOOL become_user_permanently(uid_t uid, gid_t gid)
{
/*
- * Now completely lose our privilages. This is a fairly paranoid
+ * Now completely lose our privileges. This is a fairly paranoid
* way of doing it, but it does work on all systems that I know of.
*/
/*
- * First - gain root privilage. We do this to ensure
+ * First - gain root privilege. We do this to ensure
* we can lose it again.
*/
- gain_root_privilage();
- gain_root_group_privilage();
+ gain_root_privilege();
+ gain_root_group_privilege();
#if defined(HAVE_SETRESUID) && defined(HAVE_SETRESGID)
/*
@@ -169,7 +196,7 @@ BOOL become_user_permanently(uid_t uid, gid_t gid)
if (getuid() != uid || geteuid() != uid ||
getgid() != gid || getegid() != gid) {
- /* We failed to lose our privilages. */
+ /* We failed to lose our privileges. */
return False;
}