Parionia to ensure people don't install libsmb based programs setuid root.
authorAndrew Bartlett <abartlet@samba.org>
Wed, 31 Oct 2001 01:52:34 +0000 (01:52 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 31 Oct 2001 01:52:34 +0000 (01:52 +0000)
libsmb has not been written to be setuid, with things like LIBSMB_PROG allowing
all sort of fun and games.

Andrew Bartlett
(This used to be commit 0c8e9339d8238de92e9146d04091694b62874c33)

source3/lib/util_sec.c
source3/libsmb/clientgen.c
source3/utils/smbpasswd.c

index a07e7d0e1af0ca2e3e1e1efbe101f836c5f99b58..c559647bf45e11c695c7b51eff504b05037f77f1 100644 (file)
@@ -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);
+}
index ec8d2e2bfc90942c5eb0e7dcfdd8704555ea142f..d509924a26ff9b47f48073b2aa7fe0a3ae37d3c3 100644 (file)
@@ -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)
index 6a330812e10350eab95e4874ff19cf0a9083f652..ee8bae7a4ab855d3874e952fb377da780777cffb 100644 (file)
@@ -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);
        }