summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2001-10-31 01:52:34 +0000
committerAndrew Bartlett <abartlet@samba.org>2001-10-31 01:52:34 +0000
commit0c8e9339d8238de92e9146d04091694b62874c33 (patch)
treeaecac30b3bfe1bb767a260e3160262ad06f6171f
parent190898586fa218c952fbd5bea56155d04e6f248b (diff)
downloadsamba-0c8e9339d8238de92e9146d04091694b62874c33.tar.gz
samba-0c8e9339d8238de92e9146d04091694b62874c33.tar.xz
samba-0c8e9339d8238de92e9146d04091694b62874c33.zip
Parionia to ensure people don't install libsmb based programs setuid root.
libsmb has not been written to be setuid, with things like LIBSMB_PROG allowing all sort of fun and games. Andrew Bartlett
-rw-r--r--source/lib/util_sec.c8
-rw-r--r--source/libsmb/clientgen.c6
-rw-r--r--source/utils/smbpasswd.c2
3 files changed, 15 insertions, 1 deletions
diff --git a/source/lib/util_sec.c b/source/lib/util_sec.c
index a07e7d0e1af..c559647bf45 100644
--- a/source/lib/util_sec.c
+++ b/source/lib/util_sec.c
@@ -413,3 +413,11 @@ main()
exit(0);
}
#endif
+
+/****************************************************************************
+Check if we are setuid root. Used in libsmb and smbpasswd parinoia checks.
+****************************************************************************/
+BOOL is_setuid_root(void)
+{
+ return (geteuid() == (uid_t)0) && (getuid() != (uid_t)0);
+}
diff --git a/source/libsmb/clientgen.c b/source/libsmb/clientgen.c
index ec8d2e2bfc9..d509924a26f 100644
--- a/source/libsmb/clientgen.c
+++ b/source/libsmb/clientgen.c
@@ -154,6 +154,12 @@ struct cli_state *cli_initialise(struct cli_state *cli)
{
BOOL alloced_cli = False;
+ /* Check the effective uid - make sure we are not setuid */
+ if (is_setuid_root()) {
+ DEBUG(0,("libsmb based programs must *NOT* be setuid root.\n"));
+ return NULL;
+ }
+
if (!cli) {
cli = (struct cli_state *)malloc(sizeof(*cli));
if (!cli)
diff --git a/source/utils/smbpasswd.c b/source/utils/smbpasswd.c
index 6a330812e10..ee8bae7a4ab 100644
--- a/source/utils/smbpasswd.c
+++ b/source/utils/smbpasswd.c
@@ -933,7 +933,7 @@ int main(int argc, char **argv)
strupper(global_myname);
/* Check the effective uid - make sure we are not setuid */
- if ((geteuid() == (uid_t)0) && (getuid() != (uid_t)0)) {
+ if (is_setuid_root()) {
fprintf(stderr, "smbpasswd must *NOT* be setuid root.\n");
exit(1);
}