r6149: Fixes bugs #2498 and 2484.
authorDerrell Lipman <derrell@samba.org>
Thu, 31 Mar 2005 05:06:04 +0000 (05:06 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:56:24 +0000 (10:56 -0500)
1. using smbc_getxattr() et al, one may now request all access control
   entities in the ACL without getting all other NT attributes.
2. added the ability to exclude specified attributes from the result set
   provided by smbc_getxattr() et al, when requesting all attributes,
   all NT attributes, or all DOS attributes.
3. eliminated all compiler warnings, including when --enable-developer
   compiler flags are in use.  removed -Wcast-qual flag from list, as that
   is specifically to force warnings in the case of casting away qualifiers.

Note: In the process of eliminating compiler warnings, a few nasties were
      discovered.  In the file libads/sasl.c, PRIVATE kerberos interfaces
      are being used; and in libsmb/clikrb5.c, both PRIAVE and DEPRECATED
      kerberos interfaces are being used.  Someone who knows kerberos
      should look at these and determine if there is an alternate method
      of accomplishing the task.

42 files changed:
examples/libsmbclient/README
examples/libsmbclient/testacl.c
examples/libsmbclient/testbrowse.c
examples/libsmbclient/testsmbc.c
examples/libsmbclient/teststat.c
source/client/smbspool.c
source/configure.in
source/include/includes.h
source/include/smb_macros.h
source/intl/lang_tdb.c
source/lib/access.c
source/lib/iconv.c
source/lib/smbldap.c
source/lib/util_str.c
source/lib/util_unistr.c
source/lib/util_uuid.c
source/libads/kerberos.c
source/libads/ldap.c
source/libads/ldap_printer.c
source/libads/sasl.c
source/libsmb/clikrb5.c
source/libsmb/clispnego.c
source/libsmb/libsmbclient.c
source/libsmb/spnego.c
source/modules/getdate.c
source/modules/getdate.y
source/modules/weird.c
source/nsswitch/wb_common.c
source/nsswitch/winbindd_nss.h
source/nsswitch/winbindd_rpc.c
source/nsswitch/winbindd_util.c
source/passdb/pdb_get_set.c
source/rpc_server/srv_svcctl_nt.c
source/smbd/notify_kernel.c
source/smbd/oplock_linux.c
source/smbd/sesssetup.c
source/tdb/tdb.c
source/tdb/tdbutil.c
source/utils/net_ads.c
source/utils/net_lookup.c
source/utils/smbcontrol.c
source/web/neg_lang.c

index d9a9f829174d3eeee3919282d1402b50d9471770..c45dd8b9d68cff58aaed9e3b42c6f755c5e40337 100644 (file)
@@ -2,7 +2,16 @@ Some simple example programs for libsmbclient ...
 
 testsmbc.c is kinda broken as it has many hardcoded bits in it
 
+testbrowse.c opens a remote folder and displays its contents
+
+teststat.c allows comparing the results of smbc_stat() against a local stat() of
+the same file.
+
 tree.c is an example of how you might do some of these things with GTK+
 It needs lots of work but shows you some ways to use libsmbclient.
 
-Richard Sharpe, 17-May-2001 ...
+smbwrapper implements the old smbsh/smbwrapper mechanism using libsmbclient, in
+such a way that it works on Linux
+
+Richard Sharpe, 17 May 2001
+Derrell Lipman, 30 Mar 2005
index 47668f7c9c4af4f829b121f7b06487dd90d0d8f3..ce5694b331a00f6991f0af9361bcb9ba13c75f87 100644 (file)
@@ -3,6 +3,7 @@
 #include <errno.h>
 #include <popt.h>
 #include "libsmbclient.h"
+#include "get_auth_data_fn.h"
 
 enum acl_mode
 {
@@ -15,59 +16,6 @@ enum acl_mode
     SMB_ACL_CHGRP
 };
 
-static void
-get_auth_data_fn(const char * pServer,
-                 const char * pShare,
-                 char * pWorkgroup,
-                 int maxLenWorkgroup,
-                 char * pUsername,
-                 int maxLenUsername,
-                 char * pPassword,
-                 int maxLenPassword)
-    
-{
-    char temp[128];
-    
-    fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
-    fgets(temp, sizeof(temp), stdin);
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
-    }
-    
-    fprintf(stdout, "Username: [%s] ", pUsername);
-    fgets(temp, sizeof(temp), stdin);
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pUsername, temp, maxLenUsername - 1);
-    }
-    
-    fprintf(stdout, "Password: ");
-    fgets(temp, sizeof(temp), stdin);
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pPassword, temp, maxLenPassword - 1);
-    }
-}
-
 
 int main(int argc, const char *argv[])
 {
index 8122df5e2e71837c9fce783f73117200a65e198b..27d6a6973882e377f6b4429d7ac14d742408872f 100644 (file)
@@ -5,8 +5,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <popt.h>
-#include <libsmbclient.h>
 #include <stdlib.h>
+#include <libsmbclient.h>
+#include "get_auth_data_fn.h"
 
 void error_message(char * pMessage)
 {
@@ -14,65 +15,6 @@ void error_message(char * pMessage)
 }
 
 
-static void
-get_auth_data_fn(const char * pServer,
-                 const char * pShare,
-                 char * pWorkgroup,
-                 int maxLenWorkgroup,
-                 char * pUsername,
-                 int maxLenUsername,
-                 char * pPassword,
-                 int maxLenPassword)
-    
-{
-    char temp[128];
-    
-    printf("Entered get_auth_data_fn\n");
-
-    fprintf(stdout, "Need password for //%s/%s\n", pServer, pShare);
-    
-    fprintf(stdout, "Username: [%s] ", pUsername);
-    fgets(temp, sizeof(temp), stdin);
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pUsername, temp, maxLenUsername - 1);
-    }
-    
-    strcpy(temp, getpass("Password: "));
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pPassword, temp, maxLenPassword - 1);
-    }
-
-    fprintf(stdout, "Workgroup: ");
-    fgets(temp, sizeof(temp), stdin);
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
-    }
-
-    putchar('\n');
-}
-
-
 int
 main(int argc, char * argv[])
 {
index 9f5e6148eeda844fcffe66801196c7c47873abe2..45e67bee62c63430618f3f61b09326088e8f4575 100644 (file)
 #include <unistd.h>
 #include <stdlib.h>
 #include <libsmbclient.h>
-
-void auth_fn(const char *server, const char *share,
-            char *workgroup, int wgmaxlen, char *username, int unmaxlen,
-            char *password, int pwmaxlen)
-{
-  char temp[128];
-
-  fprintf(stdout, "Need password for //%s/%s\n", server, share);
-
-  fprintf(stdout, "Enter workgroup: [%s] ", workgroup);
-  fgets(temp, sizeof(temp), stdin);
-
-  if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
-    temp[strlen(temp) - 1] = 0x00;
-
-  if (temp[0]) strncpy(workgroup, temp, wgmaxlen - 1);
-
-  fprintf(stdout, "Enter username: [%s] ", username);
-  fgets(temp, sizeof(temp), stdin);
-
-  if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
-    temp[strlen(temp) - 1] = 0x00;
-
-  if (temp[0]) strncpy(username, temp, unmaxlen - 1);
-
-  fprintf(stdout, "Enter password: [%s] ", password);
-  fgets(temp, sizeof(temp), stdin);
-
-  if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
-    temp[strlen(temp) - 1] = 0x00;
-
-  if (temp[0]) strncpy(password, temp, pwmaxlen - 1);
-
-}
+#include "get_auth_data_fn.h"
 
 int global_id = 0;
 
@@ -84,7 +51,7 @@ int main(int argc, char *argv[])
   char *dirp;
   struct stat st1, st2;
 
-  err = smbc_init(auth_fn,  10); /* Initialize things */
+  err = smbc_init(get_auth_data_fn,  10); /* Initialize things */
 
   if (err < 0) {
 
index 46eeb13985a7b0d58103957fe6b922f6531a6b95..bea34cfc098e0800a83b7846818f970411187b06 100644 (file)
@@ -3,65 +3,7 @@
 #include <string.h> 
 #include <time.h> 
 #include <libsmbclient.h> 
-
-static void
-get_auth_data_fn(const char * pServer,
-                 const char * pShare,
-                 char * pWorkgroup,
-                 int maxLenWorkgroup,
-                 char * pUsername,
-                 int maxLenUsername,
-                 char * pPassword,
-                 int maxLenPassword)
-    
-{
-    char temp[128];
-    
-    printf("Entered get_auth_data_fn\n");
-
-    fprintf(stdout, "Need password for //%s/%s\n", pServer, pShare);
-    
-    fprintf(stdout, "Username: [%s] ", pUsername);
-    fgets(temp, sizeof(temp), stdin);
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pUsername, temp, maxLenUsername - 1);
-    }
-    
-    strcpy(temp, getpass("Password: "));
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pPassword, temp, maxLenPassword - 1);
-    }
-
-    fprintf(stdout, "Workgroup: ");
-    fgets(temp, sizeof(temp), stdin);
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
-    }
-
-    putchar('\n');
-}
-
+#include "get_auth_data_fn.h"
 
 
 int main(int argc, char * argv[]) 
index 5df6bfe407e57035ed9dc42bf412902678e9d7bd..aeb4c91b19c5dc56a4812538cb2a97c54edfe2dd 100644 (file)
@@ -148,12 +148,12 @@ static int                smb_print(struct cli_state *, char *, FILE *);
     if ((password = strchr_m(username, ':')) != NULL)
       *password++ = '\0';
     else
-      password = "";
+      password = CONST_DISCARD(char *, "");
   }
   else
   {
     username = "";
-    password = "";
+    password = CONST_DISCARD(char *, "");
     server   = uri + 6;
   }
 
index 9b2f4b80ce5fc814846f2de8a5c16f260dd76b65..5ea0939f25503ded0b874d1de740827c0bae24ff 100644 (file)
@@ -248,7 +248,7 @@ fi
 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
     [if eval "test x$enable_developer = xyes"; then
         developer=yes
-       CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
+       CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
        # Add -Wdeclaration-after-statement if compiler supports it
        AC_CACHE_CHECK(
           [that the C compiler understands -Wdeclaration-after-statement],
index 982eee1886273ddfc5312a0086a2068f1f21f3f1..20f53045915583fad1e626b8d77538935e1bef66 100644 (file)
@@ -1372,4 +1372,7 @@ LDAP *ldap_open_with_timeout(const char *server, int port, unsigned int to);
 #undef HAVE_MMAP
 #endif
 
+#define CONST_DISCARD(type, ptr)      ((type) ((void *) (ptr)))
+#define CONST_ADD(type, ptr)          ((type) ((const void *) (ptr)))
+
 #endif /* _INCLUDES_H */
index 9a78718605c62c70012a97a0e8f0edfa49db3aec..2b3140783bf642b324bc1a042e9fff4394497e23 100644 (file)
@@ -43,7 +43,7 @@
  * @note You are explicitly allowed to pass NULL pointers -- they will
  * always be ignored.
  **/
-#define SAFE_FREE(x) do { if ((x) != NULL) {free((void *) (x)); x=NULL;} } while(0)
+#define SAFE_FREE(x) do { if ((x) != NULL) {free(CONST_DISCARD(void *, (x))); x=NULL;} } while(0)
 #endif
 
 /* zero a structure */
index d3422f0d78ac03d599ac2fc2898455ca083bf1be..d8f7fc8c933198e88cdb1c871fac21bc455140dd 100644 (file)
@@ -231,7 +231,7 @@ const char *lang_msg(const char *msgid)
 void lang_msg_free(const char *msgstr)
 {
        if (!tdb) return;
-       free((void *)msgstr);
+       free(CONST_DISCARD(void *, msgstr));
 }
 
 
@@ -248,7 +248,7 @@ const char *lang_msg_rotate(const char *msgid)
        static pstring bufs[NUM_LANG_BUFS];
        static int next;
 
-       msgstr = (char *)lang_msg(msgid);
+       msgstr = CONST_DISCARD(char *, lang_msg(msgid));
        if (!msgstr) return msgid;
 
        pstrcpy(bufs[next], msgstr);
index fcc795d1f266c15f80f3160990b4595a00a1f9e9..d8e40c99f76aa6790d0e4c42361f36660ac90c6e 100644 (file)
@@ -133,7 +133,7 @@ static BOOL string_match(const char *tok,const char *s, char *invalid_char)
 /* client_match - match host name and address against token */
 static BOOL client_match(const char *tok, const char *item)
 {
-       const char **client = (const char **)item;
+        const char **client = CONST_ADD(const char **, item);
        BOOL match;
        char invalid_char = '\0';
 
index d58165fed03271457f6ec31de9796215ce891d47..f23e4351c02ee97940c7e7fe64d7dae0efb07f6c 100644 (file)
@@ -135,7 +135,7 @@ static size_t sys_iconv(void *cd,
 {
 #ifdef HAVE_NATIVE_ICONV
        size_t ret = iconv((iconv_t)cd, 
-                          (char **)inbuf, inbytesleft, 
+                          CONST_DISCARD(char **, inbuf), inbytesleft, 
                           outbuf, outbytesleft);
        if (ret == (size_t)-1) {
                int saved_errno = errno;
index 78ec249717903a42c8b66ef77f966005fc3e19d1..cf2f03e0a24e248bdb34d4d285da1c4ffe992f8c 100644 (file)
@@ -1066,7 +1066,9 @@ int smbldap_search(struct smbldap_state *ldap_state,
 
        while (another_ldap_try(ldap_state, &rc, &attempts, endtime))
                rc = ldap_search_s(ldap_state->ldap_struct, base, scope, 
-                                  utf8_filter, (char **) attrs, attrsonly, res);
+                                  utf8_filter,
+                                   CONST_DISCARD(char **, attrs),
+                                   attrsonly, res);
        
        SAFE_FREE(utf8_filter);
        return rc;
@@ -1471,7 +1473,8 @@ static BOOL smbldap_check_root_dse(struct smbldap_state *ldap_state, const char
        }
 
        rc = ldap_search_s(ldap_state->ldap_struct, "", LDAP_SCOPE_BASE, 
-                          "(objectclass=*)", (char **) attrs, 0 , &msg);
+                          "(objectclass=*)", CONST_DISCARD(char **, attrs),
+                           0 , &msg);
 
        if (rc != LDAP_SUCCESS) {
                DEBUG(3,("smbldap_check_root_dse: Could not search rootDSE\n"));
index b13ec1f0dad9920f777bddd7c8957249fa2b0968..12ee3dc162ee5aa10f0ade416d4965b060c940b8 100644 (file)
@@ -45,7 +45,7 @@ BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
        if (!ptr)
                return(False);
 
-       s = (char *)*ptr;
+       s = CONST_DISCARD(char *, *ptr);
 
        /* default to simple separators */
        if (!sep)
@@ -109,7 +109,7 @@ void set_first_token(char *ptr)
 
 char **toktocliplist(int *ctok, const char *sep)
 {
-       char *s=(char *)last_ptr;
+        char *s = CONST_DISCARD(char *, last_ptr);
        int ictok=0;
        char **ret, **iret;
 
@@ -132,7 +132,7 @@ char **toktocliplist(int *ctok, const char *sep)
        } while(*s);
        
        *ctok=ictok;
-       s=(char *)last_ptr;
+       s = CONST_DISCARD(char *, last_ptr);
        
        if (!(ret=iret=SMB_MALLOC_ARRAY(char *,ictok+1)))
                return NULL;
@@ -1221,7 +1221,7 @@ char *strchr_m(const char *src, char c)
 
        for (s = src; *s && !(((unsigned char)s[0]) & 0x80); s++) {
                if (*s == c)
-                       return (char *)s;
+                       return CONST_DISCARD(char *, s);
        }
 
        if (!*s)
@@ -1238,7 +1238,7 @@ char *strchr_m(const char *src, char c)
                return NULL;
        *p = 0;
        pull_ucs2_pstring(s2, ws);
-       return (char *)(s+strlen(s2));
+       return CONST_DISCARD(char *, (s+strlen(s2)));
 }
 
 char *strrchr_m(const char *s, char c)
@@ -1275,7 +1275,7 @@ char *strrchr_m(const char *s, char c)
                                        break;
                                }
                                /* No - we have a match ! */
-                               return (char *)cp;
+                               return CONST_DISCARD(char *, cp);
                        }
                } while (cp-- != s);
                if (!got_mb)
@@ -1294,7 +1294,7 @@ char *strrchr_m(const char *s, char c)
                        return NULL;
                *p = 0;
                pull_ucs2_pstring(s2, ws);
-               return (char *)(s+strlen(s2));
+               return CONST_DISCARD(char *, (s+strlen(s2)));
        }
 }
 
@@ -1315,7 +1315,7 @@ char *strnrchr_m(const char *s, char c, unsigned int n)
                return NULL;
        *p = 0;
        pull_ucs2_pstring(s2, ws);
-       return (char *)(s+strlen(s2));
+       return CONST_DISCARD(char *, (s+strlen(s2)));
 }
 
 /***********************************************************************
@@ -1334,7 +1334,7 @@ char *strstr_m(const char *src, const char *findstr)
 
        /* for correctness */
        if (!findstr[0]) {
-               return (char*)src;
+               return CONST_DISCARD(char *, src);
        }
 
        /* Samba does single character findstr calls a *lot*. */
@@ -1351,7 +1351,7 @@ char *strstr_m(const char *src, const char *findstr)
                                findstr_len = strlen(findstr);
 
                        if (strncmp(s, findstr, findstr_len) == 0) {
-                               return (char *)s;
+                               return CONST_DISCARD(char *, s);
                        }
                }
        }
@@ -1392,7 +1392,7 @@ char *strstr_m(const char *src, const char *findstr)
                DEBUG(0,("strstr_m: dest malloc fail\n"));
                return NULL;
        }
-       retp = (char *)(s+strlen(s2));
+       retp = CONST_DISCARD(char *, (s+strlen(s2)));
        SAFE_FREE(src_w);
        SAFE_FREE(find_w);
        SAFE_FREE(s2);
index 04985c6ab6a2ea95a77b5887c137ac5f64fc6940..0b4552e1f5d918b0046cee8a534e0182a4f60384 100644 (file)
@@ -398,10 +398,10 @@ size_t strnlen_w(const smb_ucs2_t *src, size_t max)
 smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c)
 {
        while (*s != 0) {
-               if (c == *s) return (smb_ucs2_t *)s;
+                if (c == *s) return CONST_DISCARD(smb_ucs2_t *, s);
                s++;
        }
-       if (c == *s) return (smb_ucs2_t *)s;
+       if (c == *s) return CONST_DISCARD(smb_ucs2_t *, s);
 
        return NULL;
 }
@@ -422,7 +422,7 @@ smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c)
        if (len == 0) return NULL;
        p += (len - 1);
        do {
-               if (c == *p) return (smb_ucs2_t *)p;
+               if (c == *p) return CONST_DISCARD(smb_ucs2_t *, p);
        } while (p-- != s);
        return NULL;
 }
@@ -443,7 +443,7 @@ smb_ucs2_t *strnrchr_w(const smb_ucs2_t *s, smb_ucs2_t c, unsigned int n)
                        n--;
 
                if (!n)
-                       return (smb_ucs2_t *)p;
+                       return CONST_DISCARD(smb_ucs2_t *, p);
        } while (p-- != s);
        return NULL;
 }
@@ -461,7 +461,7 @@ smb_ucs2_t *strstr_w(const smb_ucs2_t *s, const smb_ucs2_t *ins)
                return NULL;
 
        inslen = strlen_w(ins);
-       r = (smb_ucs2_t *)s;
+       r = CONST_DISCARD(smb_ucs2_t *, s);
 
        while ((r = strchr_w(r, *ins))) {
                if (strncmp_w(r, ins, inslen) == 0) 
@@ -732,7 +732,7 @@ smb_ucs2_t *strpbrk_wa(const smb_ucs2_t *s, const char *p)
                int i;
                for (i=0; p[i] && *s != UCS2_CHAR(p[i]); i++) 
                        ;
-               if (p[i]) return (smb_ucs2_t *)s;
+               if (p[i]) return CONST_DISCARD(smb_ucs2_t *, s);
                s++;
        }
        return NULL;
@@ -747,7 +747,7 @@ smb_ucs2_t *strstr_wa(const smb_ucs2_t *s, const char *ins)
                return NULL;
 
        inslen = strlen(ins);
-       r = (smb_ucs2_t *)s;
+       r = CONST_DISCARD(smb_ucs2_t *, s);
 
        while ((r = strchr_w(r, UCS2_CHAR(*ins)))) {
                if (strncmp_wa(r, ins, inslen) == 0) 
index df70740b33c1b7fb5db4cd64d1c777970a80e33c..8b8e70a36efb530e0fb550a1103f488626e5daea 100644 (file)
@@ -94,7 +94,7 @@ BOOL smb_string_to_uuid(const char *in, struct uuid* uu)
 {
        BOOL ret = False;
        const char *ptr = in;
-       char *end = (char *)in;
+       char *end = CONST_DISCARD(char *, in);
        int i;
        unsigned v1, v2;
 
index 43ccb18b5a65c65c6f5da910fa03745c306c27d6..18820d9e312317c51a9eb3986797c4ccba680693 100644 (file)
@@ -89,7 +89,7 @@ int kerberos_kinit_password(const char *principal,
        }
        
        if ((code = krb5_get_init_creds_password(ctx, &my_creds, me,
-                                                 (char *) password
+                                                 CONST_DISCARD(char *, password)
                                                 kerb_prompter, 
                                                 NULL, 0, NULL, NULL))) {
                krb5_free_principal(ctx, me);
index 68103a701b7fb68f39d43f1c2f178a35b689b2bc..7a59da5a6d363f79971fbfdaeac470e47a0ec80b 100644 (file)
@@ -481,15 +481,15 @@ ADS_STATUS ads_do_paged_search(ADS_STRUCT *ads, const char *bind_path,
                ber_printf(cookie_be, "{io}", (ber_int_t) 1000, "", 0);
        }
        ber_flatten(cookie_be, &cookie_bv);
-       PagedResults.ldctl_oid = ADS_PAGE_CTL_OID;
+       PagedResults.ldctl_oid = CONST_DISCARD(char *, ADS_PAGE_CTL_OID);
        PagedResults.ldctl_iscritical = (char) 1;
        PagedResults.ldctl_value.bv_len = cookie_bv->bv_len;
        PagedResults.ldctl_value.bv_val = cookie_bv->bv_val;
 
-       NoReferrals.ldctl_oid = ADS_NO_REFERRALS_OID;
+       NoReferrals.ldctl_oid = CONST_DISCARD(char *, ADS_NO_REFERRALS_OID);
        NoReferrals.ldctl_iscritical = (char) 0;
        NoReferrals.ldctl_value.bv_len = 0;
-       NoReferrals.ldctl_value.bv_val = "";
+       NoReferrals.ldctl_value.bv_val = CONST_DISCARD(char *, "");
 
 
        controls[0] = &NoReferrals;
@@ -962,7 +962,7 @@ ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char *mod_dn, ADS_MODLIST mods)
           non-existent attribute (but allowable for the object) to run
        */
        LDAPControl PermitModify = {
-               ADS_PERMIT_MODIFY_OID,
+                CONST_DISCARD(char *, ADS_PERMIT_MODIFY_OID),
                {0, NULL},
                (char) 1};
        LDAPControl *controls[2];
index 68e6735891038a1de49a390e0cc6e8abb8189605..61275e40d11de997f7c71c1c83b8ef09e9a2725e 100644 (file)
@@ -61,8 +61,10 @@ ADS_STATUS ads_find_printers(ADS_STRUCT *ads, void **res)
 
        /* For the moment only display all printers */
 
-       ldap_expr = "(&(!(showInAdvancedViewOnly=TRUE))(uncName=*)"
-               "(objectCategory=printQueue))";
+       ldap_expr =
+                CONST_DISCARD(char *,
+                                "(&(!(showInAdvancedViewOnly=TRUE))(uncName=*)"
+                                "(objectCategory=printQueue))");
 
        return ads_search(ads, res, ldap_expr, attrs);
 }
index 0164b0c7401c54e0e555f4f8073169577136dacb..e657f2114e67a7063cde0d06c9ce7780ca61ccea 100644 (file)
@@ -18,6 +18,8 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#define KRB5_PRIVATE    1       /* this file uses PRIVATE interfaces! */
+
 #include "includes.h"
 
 #ifdef HAVE_LDAP
@@ -285,7 +287,8 @@ static ADS_STATUS ads_sasl_gssapi_bind(ADS_STRUCT *ads)
                        ENCTYPE_DES_CBC_MD5,
                        ENCTYPE_NULL};
        gss_OID_desc nt_principal = 
-       {10, "\052\206\110\206\367\022\001\002\002\002"};
+                {10, CONST_DISCARD(char *,
+                                     "\052\206\110\206\367\022\001\002\002\002")};
 
        /* we need to fetch a service ticket as the ldap user in the
           servers realm, regardless of our realm */
index 66c16b69aef4c4b882eae2f0122e46d0dd58e497..c35b53a9dd8563474042065de5364a11b5ab337b 100644 (file)
@@ -19,6 +19,9 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#define KRB5_PRIVATE    1       /* this file uses PRIVATE interfaces! */
+#define KRB5_DEPRECATED 1       /* this file uses DEPRECATED interfaces! */
+
 #include "includes.h"
 
 #ifdef HAVE_KRB5
index 85b7bd9e1eec1f3cee0d87cf33bcbd2d43c01d71..5d07999bc3a6b847a5f208c6065c4356e9677f4c 100644 (file)
@@ -338,7 +338,8 @@ int spnego_gen_negTokenTarg(const char *principal, int time_offset,
                return retval;
 
        /* wrap that up in a nice GSS-API wrapping */
-       tkt_wrapped = spnego_gen_krb5_wrap(tkt, TOK_ID_KRB_AP_REQ);
+       tkt_wrapped = spnego_gen_krb5_wrap(
+            tkt, CONST_ADD(const uint8 *, TOK_ID_KRB_AP_REQ));
 
        /* and wrap that in a shiny SPNEGO wrapper */
        *targ = gen_negTokenTarg(krb_mechs, tkt_wrapped);
index 87ca030b10384ed212520b2b0595bf3023e7aa9d..ae9a660a09a72f25059a1b1fb5e0442ce671879a 100644 (file)
@@ -3278,7 +3278,8 @@ static DOS_ATTR_DESC *dos_attr_query(SMBCCTX *context,
         }
 
         /* Obtain the DOS attributes */
-        if (!smbc_getatr(context, srv, (char *) filename, &mode, &size, 
+        if (!smbc_getatr(context, srv, CONST_DISCARD(char *, filename),
+                         &mode, &size, 
                          &c_time, &a_time, &m_time, &inode)) {
         
                 errno = smbc_errno(context, &srv->cli);
@@ -3347,21 +3348,35 @@ retrieve the acls for a file
 *******************************************************/
 static int cacl_get(SMBCCTX *context, TALLOC_CTX *ctx, SMBCSRV *srv,
                     struct cli_state *ipc_cli, POLICY_HND *pol,
-                    char *filename, char *name, char *buf, int bufsize)
+                    char *filename, char *attr_name, char *buf, int bufsize)
 {
        uint32 i;
         int n = 0;
         int n_used;
         BOOL all;
         BOOL all_nt;
+        BOOL all_nt_acls;
         BOOL all_dos;
         BOOL some_nt;
         BOOL some_dos;
+        BOOL exclude_nt_revision = False;
+        BOOL exclude_nt_owner = False;
+        BOOL exclude_nt_group = False;
+        BOOL exclude_nt_acl = False;
+        BOOL exclude_dos_mode = False;
+        BOOL exclude_dos_size = False;
+        BOOL exclude_dos_ctime = False;
+        BOOL exclude_dos_atime = False;
+        BOOL exclude_dos_mtime = False;
+        BOOL exclude_dos_inode = False;
         BOOL numeric = True;
         BOOL determine_size = (bufsize == 0);
        int fnum = -1;
        SEC_DESC *sd;
        fstring sidstr;
+        fstring name_sandbox;
+        char *name;
+        char *pExclude;
         char *p;
        time_t m_time = 0, a_time = 0, c_time = 0;
        SMB_OFF_T size = 0;
@@ -3369,20 +3384,88 @@ static int cacl_get(SMBCCTX *context, TALLOC_CTX *ctx, SMBCSRV *srv,
        SMB_INO_T ino = 0;
         struct cli_state *cli = &srv->cli;
 
+        /* Copy name so we can strip off exclusions (if any are specified) */
+        strncpy(name_sandbox, attr_name, sizeof(name_sandbox) - 1);
+
+        /* Ensure name is null terminated */
+        name_sandbox[sizeof(name_sandbox) - 1] = '\0';
+
+        /* Play in the sandbox */
+        name = name_sandbox;
+
+        /* If there are any exclusions, point to them and mask them from name */
+        if ((pExclude = strchr(name, '!')) != NULL)
+        {
+                *pExclude++ = '\0';
+        }
+
         all = (StrnCaseCmp(name, "system.*", 8) == 0);
         all_nt = (StrnCaseCmp(name, "system.nt_sec_desc.*", 20) == 0);
+        all_nt_acls = (StrnCaseCmp(name, "system.nt_sec_desc.acl.*", 24) == 0);
         all_dos = (StrnCaseCmp(name, "system.dos_attr.*", 17) == 0);
         some_nt = (StrnCaseCmp(name, "system.nt_sec_desc.", 19) == 0);
         some_dos = (StrnCaseCmp(name, "system.dos_attr.", 16) == 0);
         numeric = (* (name + strlen(name) - 1) != '+');
 
+        /* Look for exclusions from "all" requests */
+        if (all || all_nt || all_dos) {
+
+                /* Exclusions are delimited by '!' */
+                for (; pExclude != NULL; pExclude = (p == NULL ? NULL : p + 1)) {
+
+                /* Find end of this exclusion name */
+                if ((p = strchr(pExclude, '!')) != NULL)
+                {
+                    *p = '\0';
+                }
+
+                /* Which exclusion name is this? */
+                if (StrCaseCmp(pExclude, "nt_sec_desc.revision") == 0) {
+                    exclude_nt_revision = True;
+                }
+                else if (StrCaseCmp(pExclude, "nt_sec_desc.owner") == 0) {
+                    exclude_nt_owner = True;
+                }
+                else if (StrCaseCmp(pExclude, "nt_sec_desc.group") == 0) {
+                    exclude_nt_group = True;
+                }
+                else if (StrCaseCmp(pExclude, "nt_sec_desc.acl") == 0) {
+                    exclude_nt_acl = True;
+                }
+                else if (StrCaseCmp(pExclude, "dos_attr.mode") == 0) {
+                    exclude_dos_mode = True;
+                }
+                else if (StrCaseCmp(pExclude, "dos_attr.size") == 0) {
+                    exclude_dos_size = True;
+                }
+                else if (StrCaseCmp(pExclude, "dos_attr.c_time") == 0) {
+                    exclude_dos_ctime = True;
+                }
+                else if (StrCaseCmp(pExclude, "dos_attr.a_time") == 0) {
+                    exclude_dos_atime = True;
+                }
+                else if (StrCaseCmp(pExclude, "dos_attr.m_time") == 0) {
+                    exclude_dos_mtime = True;
+                }
+                else if (StrCaseCmp(pExclude, "dos_attr.inode") == 0) {
+                    exclude_dos_inode = True;
+                }
+                else {
+                    DEBUG(5, ("cacl_get received unknown exclusion: %s\n",
+                              pExclude));
+                    errno = ENOATTR;
+                    return -1;
+                }
+            }
+        }
+
         n_used = 0;
 
         /*
          * If we are (possibly) talking to an NT or new system and some NT
          * attributes have been requested...
          */
-        if (ipc_cli && (all || some_nt)) {
+        if (ipc_cli && (all || some_nt || all_nt_acls)) {
                 /* Point to the portion after "system.nt_sec_desc." */
                 name += 19;     /* if (all) this will be invalid but unused */
 
@@ -3407,139 +3490,105 @@ static int cacl_get(SMBCCTX *context, TALLOC_CTX *ctx, SMBCSRV *srv,
 
                 cli_close(cli, fnum);
 
-                if (all || all_nt) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx,
-                                                    "REVISION:%d",
-                                                    sd->revision);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+                if (! exclude_nt_revision) {
+                        if (all || all_nt) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx,
+                                                            "REVISION:%d",
+                                                            sd->revision);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize,
+                                                     "REVISION:%d", sd->revision);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize,
-                                             "REVISION:%d", sd->revision);
-                        }
-                } else if (StrCaseCmp(name, "revision") == 0) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx, "%d", sd->revision);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+                        } else if (StrCaseCmp(name, "revision") == 0) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx, "%d",
+                                                            sd->revision);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize, "%d",
+                                                     sd->revision);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize, "%d", sd->revision);
                         }
-                }
         
-                if (!determine_size && n > bufsize) {
-                        errno = ERANGE;
-                        return -1;
-                }
-                buf += n;
-                n_used += n;
-                bufsize -= n;
-
-                /* Get owner and group sid */
-
-                if (sd->owner_sid) {
-                        convert_sid_to_string(ipc_cli, pol,
-                                              sidstr, numeric, sd->owner_sid);
-                } else {
-                        fstrcpy(sidstr, "");
+                        if (!determine_size && n > bufsize) {
+                                errno = ERANGE;
+                                return -1;
+                        }
+                        buf += n;
+                        n_used += n;
+                        bufsize -= n;
                 }
 
-                if (all || all_nt) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx, ",OWNER:%s", sidstr);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
-                                }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize,
-                                             ",OWNER:%s", sidstr);
-                        }
-                } else if (StrnCaseCmp(name, "owner", 5) == 0) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx, "%s", sidstr);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
-                                }
-                                n = strlen(p);
+                if (! exclude_nt_owner) {
+                        /* Get owner and group sid */
+                        if (sd->owner_sid) {
+                                convert_sid_to_string(ipc_cli, pol,
+                                                      sidstr,
+                                                      numeric,
+                                                      sd->owner_sid);
                         } else {
-                                n = snprintf(buf, bufsize, "%s", sidstr);
+                                fstrcpy(sidstr, "");
                         }
-                }
 
-                if (!determine_size && n > bufsize) {
-                        errno = ERANGE;
-                        return -1;
-                }
-                buf += n;
-                n_used += n;
-                bufsize -= n;
-
-                if (sd->grp_sid) {
-                        convert_sid_to_string(ipc_cli, pol,
-                                              sidstr, numeric, sd->grp_sid);
-                } else {
-                        fstrcpy(sidstr, "");
-                }
-
-                if (all || all_nt) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx, ",GROUP:%s", sidstr);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+                        if (all || all_nt) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx, ",OWNER:%s",
+                                                            sidstr);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize,
+                                                     ",OWNER:%s", sidstr);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize,
-                                             ",GROUP:%s", sidstr);
-                        }
-                } else if (StrnCaseCmp(name, "group", 5) == 0) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx, "%s", sidstr);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+                        } else if (StrnCaseCmp(name, "owner", 5) == 0) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx, "%s", sidstr);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize, "%s",
+                                                     sidstr);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize, "%s", sidstr);
                         }
-                }
 
-                if (!determine_size && n > bufsize) {
-                        errno = ERANGE;
-                        return -1;
+                        if (!determine_size && n > bufsize) {
+                                errno = ERANGE;
+                                return -1;
+                        }
+                        buf += n;
+                        n_used += n;
+                        bufsize -= n;
                 }
-                buf += n;
-                n_used += n;
-                bufsize -= n;
 
-                /* Add aces to value buffer  */
-                for (i = 0; sd->dacl && i < sd->dacl->num_aces; i++) {
-
-                        SEC_ACE *ace = &sd->dacl->ace[i];
-                        convert_sid_to_string(ipc_cli, pol,
-                                              sidstr, numeric, &ace->trustee);
+                if (! exclude_nt_group) {
+                        if (sd->grp_sid) {
+                                convert_sid_to_string(ipc_cli, pol,
+                                                      sidstr, numeric,
+                                                      sd->grp_sid);
+                        } else {
+                                fstrcpy(sidstr, "");
+                        }
 
                         if (all || all_nt) {
                                 if (determine_size) {
-                                        p = talloc_asprintf(ctx, 
-                                                            ",ACL:"
-                                                            "%s:%d/%d/0x%08x", 
-                                                            sidstr,
-                                                            ace->type,
-                                                            ace->flags,
-                                                            ace->info.mask);
+                                        p = talloc_asprintf(ctx, ",GROUP:%s",
+                                                            sidstr);
                                         if (!p) {
                                                 errno = ENOMEM;
                                                 return -1;
@@ -3547,36 +3596,22 @@ static int cacl_get(SMBCCTX *context, TALLOC_CTX *ctx, SMBCSRV *srv,
                                         n = strlen(p);
                                 } else {
                                         n = snprintf(buf, bufsize,
-                                                     ",ACL:%s:%d/%d/0x%08x", 
-                                                     sidstr,
-                                                     ace->type,
-                                                     ace->flags,
-                                                     ace->info.mask);
+                                                     ",GROUP:%s", sidstr);
                                 }
-                        } else if ((StrnCaseCmp(name, "acl", 3) == 0 &&
-                                    StrCaseCmp(name + 3, sidstr) == 0) ||
-                                   (StrnCaseCmp(name, "acl+", 4) == 0 &&
-                                    StrCaseCmp(name + 4, sidstr) == 0)) {
+                        } else if (StrnCaseCmp(name, "group", 5) == 0) {
                                 if (determine_size) {
-                                        p = talloc_asprintf(ctx, 
-                                                            "%d/%d/0x%08x", 
-                                                            ace->type,
-                                                            ace->flags,
-                                                            ace->info.mask);
+                                        p = talloc_asprintf(ctx, "%s", sidstr);
                                         if (!p) {
                                                 errno = ENOMEM;
                                                 return -1;
                                         }
                                         n = strlen(p);
                                 } else {
-                                        n = snprintf(buf, bufsize,
-                                                     "%d/%d/0x%08x", 
-                                                     ace->type,
-                                                     ace->flags,
-                                                     ace->info.mask);
+                                        n = snprintf(buf, bufsize, "%s", sidstr);
                                 }
                         }
-                        if (n > bufsize) {
+
+                        if (!determine_size && n > bufsize) {
                                 errno = ERANGE;
                                 return -1;
                         }
@@ -3585,6 +3620,97 @@ static int cacl_get(SMBCCTX *context, TALLOC_CTX *ctx, SMBCSRV *srv,
                         bufsize -= n;
                 }
 
+                if (! exclude_nt_acl) {
+                        /* Add aces to value buffer  */
+                        for (i = 0; sd->dacl && i < sd->dacl->num_aces; i++) {
+
+                                SEC_ACE *ace = &sd->dacl->ace[i];
+                                convert_sid_to_string(ipc_cli, pol,
+                                                      sidstr, numeric,
+                                                      &ace->trustee);
+
+                                if (all || all_nt) {
+                                        if (determine_size) {
+                                                p = talloc_asprintf(
+                                                        ctx, 
+                                                        ",ACL:"
+                                                        "%s:%d/%d/0x%08x", 
+                                                        sidstr,
+                                                        ace->type,
+                                                        ace->flags,
+                                                        ace->info.mask);
+                                                if (!p) {
+                                                        errno = ENOMEM;
+                                                        return -1;
+                                                }
+                                                n = strlen(p);
+                                        } else {
+                                                n = snprintf(
+                                                        buf, bufsize,
+                                                        ",ACL:%s:%d/%d/0x%08x", 
+                                                        sidstr,
+                                                        ace->type,
+                                                        ace->flags,
+                                                        ace->info.mask);
+                                        }
+                                } else if ((StrnCaseCmp(name, "acl", 3) == 0 &&
+                                            StrCaseCmp(name + 3, sidstr) == 0) ||
+                                           (StrnCaseCmp(name, "acl+", 4) == 0 &&
+                                            StrCaseCmp(name + 4, sidstr) == 0)) {
+                                        if (determine_size) {
+                                                p = talloc_asprintf(
+                                                        ctx, 
+                                                        "%d/%d/0x%08x", 
+                                                        ace->type,
+                                                        ace->flags,
+                                                        ace->info.mask);
+                                                if (!p) {
+                                                        errno = ENOMEM;
+                                                        return -1;
+                                                }
+                                                n = strlen(p);
+                                        } else {
+                                                n = snprintf(buf, bufsize,
+                                                             "%d/%d/0x%08x", 
+                                                             ace->type,
+                                                             ace->flags,
+                                                             ace->info.mask);
+                                        }
+                                } else if (all_nt_acls) {
+                                        if (determine_size) {
+                                                p = talloc_asprintf(
+                                                        ctx, 
+                                                        "%s%s:%d/%d/0x%08x",
+                                                        i ? "," : "",
+                                                        sidstr,
+                                                        ace->type,
+                                                        ace->flags,
+                                                        ace->info.mask);
+                                                if (!p) {
+                                                        errno = ENOMEM;
+                                                        return -1;
+                                                }
+                                                n = strlen(p);
+                                        } else {
+                                                n = snprintf(buf, bufsize,
+                                                             "%s%s:%d/%d/0x%08x",
+                                                             i ? "," : "",
+                                                             sidstr,
+                                                             ace->type,
+                                                             ace->flags,
+                                                             ace->info.mask);
+                                        }
+                                }
+                                if (n > bufsize) {
+                                        errno = ERANGE;
+                                        return -1;
+                                }
+                                buf += n;
+                                n_used += n;
+                                bufsize -= n;
+                        }
+                }
+
                 /* Restore name pointer to its original value */
                 name -= 19;
         }
@@ -3602,231 +3728,250 @@ static int cacl_get(SMBCCTX *context, TALLOC_CTX *ctx, SMBCSRV *srv,
                         
                 }
                 
-                if (all || all_dos) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx,
-                                                    "%sMODE:0x%x",
-                                                    (ipc_cli &&
-                                                     (all || some_nt)
-                                                     ? ","
-                                                     : ""),
-                                                    mode);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+                if (! exclude_dos_mode) {
+                        if (all || all_dos) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx,
+                                                            "%sMODE:0x%x",
+                                                            (ipc_cli &&
+                                                             (all || some_nt)
+                                                             ? ","
+                                                             : ""),
+                                                            mode);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize,
+                                                     "%sMODE:0x%x",
+                                                     (ipc_cli &&
+                                                      (all || some_nt)
+                                                      ? ","
+                                                      : ""),
+                                                     mode);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize,
-                                             "%sMODE:0x%x",
-                                             (ipc_cli &&
-                                              (all || some_nt)
-                                              ? ","
-                                              : ""),
-                                             mode);
-                        }
-                } else if (StrCaseCmp(name, "mode") == 0) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx, "0x%x", mode);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+                        } else if (StrCaseCmp(name, "mode") == 0) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx, "0x%x", mode);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize, "0x%x", mode);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize, "0x%x", mode);
                         }
-                }
         
-                if (!determine_size && n > bufsize) {
-                        errno = ERANGE;
-                        return -1;
+                        if (!determine_size && n > bufsize) {
+                                errno = ERANGE;
+                                return -1;
+                        }
+                        buf += n;
+                        n_used += n;
+                        bufsize -= n;
                 }
-                buf += n;
-                n_used += n;
-                bufsize -= n;
-
-                if (all || all_dos) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx,
-                                                    ",SIZE:%llu",
-                                                    (unsigned long long) size);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+
+                if (! exclude_dos_size) {
+                        if (all || all_dos) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(
+                                                ctx,
+                                                ",SIZE:%llu",
+                                                (unsigned long long) size);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize,
+                                                     ",SIZE:%llu",
+                                                     (unsigned long long) size);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize,
-                                             ",SIZE:%llu",
-                                             (unsigned long long) size);
-                        }
-                } else if (StrCaseCmp(name, "size") == 0) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx,
-                                                    "%llu",
-                                                    (unsigned long long) size);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+                        } else if (StrCaseCmp(name, "size") == 0) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(
+                                                ctx,
+                                                "%llu",
+                                                (unsigned long long) size);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize,
+                                                     "%llu",
+                                                     (unsigned long long) size);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize,
-                                             "%llu",
-                                             (unsigned long long) size);
                         }
-                }
         
-                if (!determine_size && n > bufsize) {
-                        errno = ERANGE;
-                        return -1;
+                        if (!determine_size && n > bufsize) {
+                                errno = ERANGE;
+                                return -1;
+                        }
+                        buf += n;
+                        n_used += n;
+                        bufsize -= n;
                 }
-                buf += n;
-                n_used += n;
-                bufsize -= n;
-
-                if (all || all_dos) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx,
-                                                    ",C_TIME:%lu", c_time);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+
+                if (! exclude_dos_ctime) {
+                        if (all || all_dos) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx,
+                                                            ",C_TIME:%lu",
+                                                            c_time);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize,
+                                                     ",C_TIME:%lu", c_time);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize,
-                                             ",C_TIME:%lu", c_time);
-                        }
-                } else if (StrCaseCmp(name, "c_time") == 0) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx, "%lu", c_time);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+                        } else if (StrCaseCmp(name, "c_time") == 0) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx, "%lu", c_time);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize, "%lu", c_time);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize, "%lu", c_time);
                         }
-                }
         
-                if (!determine_size && n > bufsize) {
-                        errno = ERANGE;
-                        return -1;
+                        if (!determine_size && n > bufsize) {
+                                errno = ERANGE;
+                                return -1;
+                        }
+                        buf += n;
+                        n_used += n;
+                        bufsize -= n;
                 }
-                buf += n;
-                n_used += n;
-                bufsize -= n;
-
-                if (all || all_dos) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx,
-                                                    ",A_TIME:%lu", a_time);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+
+                if (! exclude_dos_atime) {
+                        if (all || all_dos) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx,
+                                                            ",A_TIME:%lu",
+                                                            a_time);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize,
+                                                     ",A_TIME:%lu", a_time);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize,
-                                             ",A_TIME:%lu", a_time);
-                        }
-                } else if (StrCaseCmp(name, "a_time") == 0) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx, "%lu", a_time);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+                        } else if (StrCaseCmp(name, "a_time") == 0) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx, "%lu", a_time);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize, "%lu", a_time);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize, "%lu", a_time);
                         }
-                }
         
-                if (!determine_size && n > bufsize) {
-                        errno = ERANGE;
-                        return -1;
+                        if (!determine_size && n > bufsize) {
+                                errno = ERANGE;
+                                return -1;
+                        }
+                        buf += n;
+                        n_used += n;
+                        bufsize -= n;
                 }
-                buf += n;
-                n_used += n;
-                bufsize -= n;
-
-                if (all || all_dos) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx,
-                                                    ",M_TIME:%lu", m_time);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+
+                if (! exclude_dos_mtime) {
+                        if (all || all_dos) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx,
+                                                            ",M_TIME:%lu",
+                                                            m_time);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize,
+                                                     ",M_TIME:%lu", m_time);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize,
-                                             ",M_TIME:%lu", m_time);
-                        }
-                } else if (StrCaseCmp(name, "m_time") == 0) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx, "%lu", m_time);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+                        } else if (StrCaseCmp(name, "m_time") == 0) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(ctx, "%lu", m_time);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize, "%lu", m_time);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize, "%lu", m_time);
                         }
-                }
         
-                if (!determine_size && n > bufsize) {
-                        errno = ERANGE;
-                        return -1;
+                        if (!determine_size && n > bufsize) {
+                                errno = ERANGE;
+                                return -1;
+                        }
+                        buf += n;
+                        n_used += n;
+                        bufsize -= n;
                 }
-                buf += n;
-                n_used += n;
-                bufsize -= n;
-
-                if (all || all_dos) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx,
-                                                    ",INODE:%llu",
-                                                    (unsigned long long) ino);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+
+                if (! exclude_dos_inode) {
+                        if (all || all_dos) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(
+                                                ctx,
+                                                ",INODE:%llu",
+                                                (unsigned long long) ino);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize,
+                                                     ",INODE:%llu",
+                                                     (unsigned long long) ino);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize,
-                                             ",INODE:%llu",
-                                             (unsigned long long) ino);
-                        }
-                } else if (StrCaseCmp(name, "inode") == 0) {
-                        if (determine_size) {
-                                p = talloc_asprintf(ctx,
-                                                    "%llu",
-                                                    (unsigned long long) ino);
-                                if (!p) {
-                                        errno = ENOMEM;
-                                        return -1;
+                        } else if (StrCaseCmp(name, "inode") == 0) {
+                                if (determine_size) {
+                                        p = talloc_asprintf(
+                                                ctx,
+                                                "%llu",
+                                                (unsigned long long) ino);
+                                        if (!p) {
+                                                errno = ENOMEM;
+                                                return -1;
+                                        }
+                                        n = strlen(p);
+                                } else {
+                                        n = snprintf(buf, bufsize,
+                                                     "%llu",
+                                                     (unsigned long long) ino);
                                 }
-                                n = strlen(p);
-                        } else {
-                                n = snprintf(buf, bufsize,
-                                             "%llu",
-                                             (unsigned long long) ino);
                         }
-                }
         
-                if (!determine_size && n > bufsize) {
-                        errno = ERANGE;
-                        return -1;
+                        if (!determine_size && n > bufsize) {
+                                errno = ERANGE;
+                                return -1;
+                        }
+                        buf += n;
+                        n_used += n;
+                        bufsize -= n;
                 }
-                buf += n;
-                n_used += n;
-                bufsize -= n;
 
                 /* Restore name pointer to its original value */
                 name -= 16;
@@ -3873,7 +4018,8 @@ static int cacl_set(TALLOC_CTX *ctx, struct cli_state *cli,
                         the_acl = p + 1;
                 }
 
-                sd = sec_desc_parse(ctx, ipc_cli, pol, numeric, (char *) the_acl);
+                sd = sec_desc_parse(ctx, ipc_cli, pol, numeric,
+                                    CONST_DISCARD(char *, the_acl));
 
                 if (!sd) {
                         errno = EINVAL;
@@ -4380,9 +4526,13 @@ int smbc_getxattr_ctx(SMBCCTX *context,
 
         /* Are they requesting a supported attribute? */
         if (StrCaseCmp(name, "system.*") == 0 ||
+            StrnCaseCmp(name, "system.*!", 9) == 0 ||
             StrCaseCmp(name, "system.*+") == 0 ||
+            StrnCaseCmp(name, "system.*+!", 10) == 0 ||
             StrCaseCmp(name, "system.nt_sec_desc.*") == 0 ||
+            StrnCaseCmp(name, "system.nt_sec_desc.*!", 21) == 0 ||
             StrCaseCmp(name, "system.nt_sec_desc.*+") == 0 ||
+            StrnCaseCmp(name, "system.nt_sec_desc.*+!", 22) == 0 ||
             StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 ||
             StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 ||
             StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0 ||
@@ -4391,6 +4541,7 @@ int smbc_getxattr_ctx(SMBCCTX *context,
             StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 ||
             StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0 ||
             StrCaseCmp(name, "system.dos_attr.*") == 0 ||
+            StrnCaseCmp(name, "system.dos_attr.*!", 18) == 0 ||
             StrCaseCmp(name, "system.dos_attr.mode") == 0 ||
             StrCaseCmp(name, "system.dos_attr.size") == 0 ||
             StrCaseCmp(name, "system.dos_attr.c_time") == 0 ||
@@ -4401,7 +4552,9 @@ int smbc_getxattr_ctx(SMBCCTX *context,
                 /* Yup. */
                 ret = cacl_get(context, ctx, srv,
                                ipc_srv == NULL ? NULL : &ipc_srv->cli, 
-                               &pol, path, (char *) name, (char *) value, size);
+                               &pol, path,
+                               CONST_DISCARD(char *, name),
+                               CONST_DISCARD(char *, value), size);
                 if (ret < 0 && errno == 0) {
                         errno = smbc_errno(context, &srv->cli);
                 }
@@ -4540,6 +4693,7 @@ int smbc_listxattr_ctx(SMBCCTX *context,
                 "system.nt_sec_desc.owner+\0"
                 "system.nt_sec_desc.group\0"
                 "system.nt_sec_desc.group+\0"
+                "system.nt_sec_desc.acl.*\0"
                 "system.nt_sec_desc.acl\0"
                 "system.nt_sec_desc.acl+\0"
                 "system.nt_sec_desc.*\0"
index 090148d415f9b0b83d7e2f97c60834b1276eb013..0387e8f67d84c35ad9c8c40fb949c32b69ea5d6e 100644 (file)
@@ -47,7 +47,9 @@ static BOOL read_negTokenInit(ASN1_DATA *asn1, negTokenInit_t *token)
                                     0 < asn1_tag_remaining(asn1); i++) {
                                token->mechTypes = 
                                        SMB_REALLOC_ARRAY(token->mechTypes, const char *, i + 2);
-                               asn1_read_OID(asn1, (char **) (token->mechTypes + i));
+                               asn1_read_OID(asn1,
+                                              CONST_DISCARD(char **,
+                                                              (token->mechTypes + i)));
                        }
                        token->mechTypes[i] = NULL;
                        
@@ -182,7 +184,7 @@ static BOOL read_negTokenTarg(ASN1_DATA *asn1, negTokenTarg_t *token)
                        break;
                case ASN1_CONTEXT(1):
                        asn1_start_tag(asn1, ASN1_CONTEXT(1));
-                       asn1_read_OID(asn1, (char **) &token->supportedMech);
+                       asn1_read_OID(asn1, CONST_DISCARD(char **, &token->supportedMech));
                        asn1_end_tag(asn1);
                        break;
                case ASN1_CONTEXT(2):
@@ -317,7 +319,8 @@ BOOL free_spnego_data(SPNEGO_DATA *spnego)
                if (spnego->negTokenInit.mechTypes) {
                        int i;
                        for (i = 0; spnego->negTokenInit.mechTypes[i]; i++) {
-                               free((void *) spnego->negTokenInit.mechTypes[i]);
+                               free(CONST_DISCARD(void *,
+                                                     spnego->negTokenInit.mechTypes[i]));
                        }
                        free(spnego->negTokenInit.mechTypes);
                }
@@ -326,7 +329,7 @@ BOOL free_spnego_data(SPNEGO_DATA *spnego)
                break;
        case SPNEGO_NEG_TOKEN_TARG:
                if (spnego->negTokenTarg.supportedMech) {
-                       free((void *) spnego->negTokenTarg.supportedMech);
+                       free(CONST_DISCARD(void *, spnego->negTokenTarg.supportedMech));
                }
                data_blob_free(&spnego->negTokenTarg.responseToken);
                data_blob_free(&spnego->negTokenTarg.mechListMIC);
index 491c51294e9ca0e68704250b126865671c7229e8..2ce07f898caff989d6cc0ee2d4bdec112199d083 100644 (file)
    the right thing about local DST.  Unlike previous versions, this
    version is reentrant.  */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-# ifdef HAVE_ALLOCA_H
-#  include <alloca.h>
-# endif
+#include <config.h>
+
+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
 #endif
 
 /* Since the code of getdate.y is not included in the Emacs executable
index aab37f4d23554163fcab0c5de345af340d58c9ee..ecae7311ac8628dec99a78a62d83ae7297a501b0 100644 (file)
    the right thing about local DST.  Unlike previous versions, this
    version is reentrant.  */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-# ifdef HAVE_ALLOCA_H
-#  include <alloca.h>
-# endif
+#include <config.h>
+
+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
 #endif
 
 /* Since the code of getdate.y is not included in the Emacs executable
index 3c59fd9d61f18b35115df84d0cb64b468524fd05..e4809a64c4271c7a97bb195ac62105271aeeda65 100644 (file)
@@ -26,8 +26,8 @@ static struct {
        char *to;
        int len;
 } weird_table[] = {
-       {'q', "^q^", 3},
-       {'Q', "^Q^", 3},
+       {'q', CONST_DISCARD(char *, "^q^"), 3},
+       {'Q', CONST_DISCARD(char *, "^Q^"), 3},
        {0, NULL}
 };
 
index 9caf7affc3934a2e517e1bf4be20c46ae17f63fc..6ba0cbbf4287cd1fc4d039a48c281621d117552d 100644 (file)
@@ -26,6 +26,9 @@
 
 #include "winbind_client.h"
 
+#define CONST_DISCARD(type, ptr)      ((type) ((void *) (ptr)))
+#define CONST_ADD(type, ptr)          ((type) ((const void *) (ptr)))
+
 /* Global variables.  These are effectively the client state information */
 
 int winbindd_fd = -1;           /* fd for winbindd socket */
@@ -606,14 +609,14 @@ NSS_STATUS winbindd_request(int req_type,
 
 BOOL winbind_off( void )
 {
-       static char *s = WINBINDD_DONT_ENV "=1";
+        static char *s = CONST_DISCARD(char *, WINBINDD_DONT_ENV "=1");
 
        return putenv(s) != -1;
 }
 
 BOOL winbind_on( void )
 {
-       static char *s = WINBINDD_DONT_ENV "=0";
+       static char *s = CONST_DISCARD(char *, WINBINDD_DONT_ENV "=0");
 
        return putenv(s) != -1;
 }
index 838ba1e211efa838217f5274d7960bf9947decf9..06ebd68f8f80ae0d8fd9f14bff43306fdeb2c21a 100644 (file)
@@ -11,7 +11,7 @@
 */
 
 #ifndef SAFE_FREE
-#define SAFE_FREE(x) do { if(x) {free((void *) (x)); x=NULL;} } while(0)
+#define SAFE_FREE(x) do { if(x) {free(CONST_DISCARD(void *, (x))); x=NULL;} } while(0)
 #endif
 
 #ifndef _WINBINDD_NTDOM_H
index 5e974736e3d21bbcb979d9ee2a1b0e69221d4ec2..1dfa810a8d3869e1f30718761ef8ee6e3d16310a 100644 (file)
@@ -789,7 +789,7 @@ static int get_ldap_seq(const char *server, int port, uint32 *seq)
        to.tv_usec = 0;
 
        if (ldap_search_st(ldp, "", LDAP_SCOPE_BASE, "(objectclass=*)",
-                           (char **) &attrs[0], 0, &to, &res))
+                           CONST_DISCARD(char **, &attrs[0]), 0, &to, &res))
                goto done;
 
        if (ldap_count_entries(ldp, res) != 1)
index 3d03d6f4cc49aa74656dc30e7b4013d094b5b7c6..9ae24e401fdd2f1e2fddc1341370cada4527632d 100644 (file)
@@ -636,7 +636,7 @@ BOOL parse_domain_user(const char *domuser, fstring domain, fstring user)
 */
 void fill_domain_username(fstring name, const char *domain, const char *user)
 {
-        strlower_m( (char *) user );
+        strlower_m(CONST_DISCARD(char *, user));
 
        if (assume_domain(domain)) {
                strlcpy(name, user, sizeof(fstring));
index 4b59b5fdf95a171a055ed064f1cc3c8b6c8832e7..99afac133acbc3a729a97908284a9ce0d4133863 100644 (file)
@@ -1195,7 +1195,7 @@ BOOL pdb_set_plaintext_passwd (SAM_ACCOUNT *sampass, const char *plaintext)
                        /* We need to make sure we don't have a race condition here - the
                           account policy history length can change between when the pw_history
                           was first loaded into the SAM_ACCOUNT struct and now.... JRA. */
-                       pwhistory = (uchar *)pdb_get_pw_history(sampass, &current_history_len);
+                       pwhistory = CONST_DISCARD(uchar *, pdb_get_pw_history(sampass, &current_history_len));
 
                        if (current_history_len != pwHistLen) {
                                /* After closing and reopening SAM_ACCOUNT the history
index cb04ef1d10f5af95b9257123ed684497e98b92dd..a76e68a312c91f2971f201a8b6db1cf36daf87a0 100644 (file)
  * sertup the \PIPE\svcctl db API
  */
  
-static TDB_CONTEXT *svcctl_tdb; /* used for share security descriptors */
-
 #define SCVCTL_DATABASE_VERSION_V1 1
 
 /********************************************************************
 ********************************************************************/
 
-#if 0 /* unused static function */
+#if 0 /* unused static function and static variable*/
+
+static TDB_CONTEXT *svcctl_tdb; /* used for share security descriptors */
 
 static BOOL init_svcctl_db( void )
 {
index 8fcc18a09f9645264099d1b03f862971fdfaee46..c368fd79a129954ee27c8225a25fd369be42bd2c 100644 (file)
@@ -101,8 +101,9 @@ static BOOL kernel_check_notify(connection_struct *conn, uint16 vuid, char *path
                        close((int)fd_pending_array[i]);
                        fd_pending_array[i] = (SIG_ATOMIC_T)-1;
                        if (signals_received - i - 1) {
-                               memmove((void *)&fd_pending_array[i], (void *)&fd_pending_array[i+1],
-                                               sizeof(SIG_ATOMIC_T)*(signals_received-i-1));
+                               memmove(CONST_DISCARD(void *, &fd_pending_array[i]),
+                                        CONST_DISCARD(void *, &fd_pending_array[i+1]),
+                                        sizeof(SIG_ATOMIC_T)*(signals_received-i-1));
                        }
                        data->directory_handle = -1;
                        signals_received--;
@@ -129,8 +130,9 @@ static void kernel_remove_notify(void *datap)
                        if (fd == (int)fd_pending_array[i]) {
                                fd_pending_array[i] = (SIG_ATOMIC_T)-1;
                                if (signals_received - i - 1) {
-                                       memmove((void *)&fd_pending_array[i], (void *)&fd_pending_array[i+1],
-                                                       sizeof(SIG_ATOMIC_T)*(signals_received-i-1));
+                                       memmove(CONST_DISCARD(void *, &fd_pending_array[i]),
+                                                CONST_DISCARD(void *, &fd_pending_array[i+1]),
+                                                sizeof(SIG_ATOMIC_T)*(signals_received-i-1));
                                }
                                data->directory_handle = -1;
                                signals_received--;
index 5de9dd56e68d8cb7175efbeccaa1580df25e0f60..fe324577e11ccc4b884a155f88a0da1de1f88871 100644 (file)
@@ -69,16 +69,21 @@ static void set_capability(unsigned capability)
 #define _LINUX_CAPABILITY_VERSION 0x19980330
 #endif
        /* these can be removed when they are in glibc headers */
-       struct  {
+       struct  cap_user_header {
                uint32 version;
                int pid;
        } header;
-       struct {
+       struct cap_user_data {
                uint32 effective;
                uint32 permitted;
                uint32 inheritable;
        } data;
 
+        extern int capget(struct cap_user_header * hdrp,
+                          struct cap_user_data * datap);
+        extern int capset(struct cap_user_header * hdrp,
+                          const struct cap_user_data * datap);
+
        header.version = _LINUX_CAPABILITY_VERSION;
        header.pid = 0;
 
@@ -133,7 +138,8 @@ static BOOL linux_oplock_receive_message(fd_set *fds, char *buffer, int buffer_l
        fsp = file_find_fd(fd);
        fd_pending_array[0] = (SIG_ATOMIC_T)-1;
        if (signals_received > 1)
-               memmove((void *)&fd_pending_array[0], (void *)&fd_pending_array[1],
+                memmove(CONST_DISCARD(void *, &fd_pending_array[0]),
+                        CONST_DISCARD(void *, &fd_pending_array[1]),
                        sizeof(SIG_ATOMIC_T)*(signals_received-1));
        signals_received--;
        /* now we can receive more signals */
index 48524b472d2d1923339c29a8f1d59538e75e0981..60867df6535a75bd07c746e04174cff2acb90212 100644 (file)
@@ -313,7 +313,9 @@ static int reply_spnego_kerberos(connection_struct *conn,
 
         /* wrap that up in a nice GSS-API wrapping */
        if (NT_STATUS_IS_OK(ret)) {
-               ap_rep_wrapped = spnego_gen_krb5_wrap(ap_rep, TOK_ID_KRB_AP_REP);
+               ap_rep_wrapped = spnego_gen_krb5_wrap(
+                        ap_rep,
+                        CONST_ADD(const uint8 *, TOK_ID_KRB_AP_REP));
        } else {
                ap_rep_wrapped = data_blob(NULL, 0);
        }
index 0644b64da0946a90e9ee1d997854d6e7b65adef1..f153e2f25823b88789be9d502039160db50595eb 100644 (file)
 
 /* free memory if the pointer is valid and zero the pointer */
 #ifndef SAFE_FREE
-#define SAFE_FREE(x) do { if ((x) != NULL) {free((void *) (x)); (x)=NULL;} } while(0)
+#define SAFE_FREE(x) do { if ((x) != NULL) {free(CONST_DISCARD(void *, (x))); (x)=NULL;} } while(0)
 #endif
 
 #define BUCKET(hash) ((hash) % tdb->header.hash_size)
index 29fbd259044acffa7418200e682ecdf66f6f1a19..4fcfb6185aefb6c8352c7d0e2a418e9247760c8a 100644 (file)
@@ -43,7 +43,7 @@ static void gotalarm_sig(void)
 TDB_DATA make_tdb_data(const char *dptr, size_t dsize)
 {
        TDB_DATA ret;
-       ret.dptr = (char *) dptr;
+       ret.dptr = CONST_DISCARD(char *, dptr);
        ret.dsize = dsize;
        return ret;
 }
@@ -62,7 +62,7 @@ static int tdb_chainlock_with_timeout_internal( TDB_CONTEXT *tdb, TDB_DATA key,
        /* Allow tdb_chainlock to be interrupted by an alarm. */
        int ret;
        gotalarm = 0;
-       tdb_set_lock_alarm((sig_atomic_t *) &gotalarm);
+       tdb_set_lock_alarm(CONST_DISCARD(sig_atomic_t *, &gotalarm));
 
        if (timeout) {
                CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
index 83fdb08a9a8423faca6bf372b82276ce3604e468..34a357cd46d2f3c86b76866ef3174adf6cdd522b 100644 (file)
@@ -81,7 +81,7 @@ static int net_ads_lookup(int argc, const char **argv)
                d_printf("Didn't find the cldap server!\n");
                return -1;
        } if (!ads->config.realm) {
-                ads->config.realm = (char *) opt_target_workgroup;
+                ads->config.realm = CONST_DISCARD(char *, opt_target_workgroup);
                ads->ldap_port = 389;
        }
 
@@ -1168,7 +1168,7 @@ static int net_ads_password(int argc, const char **argv)
        }
 
        if (argv[1]) {
-               new_password = (char *)argv[1];
+               new_password = CONST_DISCARD(char *, argv[1]);
        } else {
                asprintf(&prompt, "Enter new password for %s:", user);
                new_password = getpass(prompt);
index 7f7a88c66db3c4e8f55541c9763270c6978d2442..9ddfe62508129681ee149125038ac555ed86376f 100644 (file)
@@ -193,7 +193,7 @@ static int net_lookup_kdc(int argc, const char **argv)
        }
 
        if (argc>0) {
-               realm.data = (krb5_pointer) argv[0];
+                realm.data = CONST_DISCARD(krb5_pointer, argv[0]);
                realm.length = strlen(argv[0]);
        } else if (lp_realm() && *lp_realm()) {
                realm.data = (krb5_pointer) lp_realm();
index 154bc5b1ae429d8dde252c169e2dea031b621b5b..5a7b6548c29cb4ad0b07810fc2c3ef62b0dd1d6c 100644 (file)
@@ -428,7 +428,8 @@ static BOOL do_printnotify(const pid_t pid, const int argc, const char **argv)
                        return False;
                }
 
-               notify_printer_byname(argv[2], attribute, (char *) argv[4]);
+               notify_printer_byname(argv[2], attribute,
+                                      CONST_DISCARD(char *, argv[4]));
 
                goto send;
        }
index ca671822d87a7f3301049fba276e55addd735b8c..cc2924afde6982da66fdbed8ae8a9c66099abd98 100644 (file)
@@ -54,8 +54,8 @@ struct pri_list {
 };
 
 static int qsort_cmp_list(const void *x, const void *y) {
-       struct pri_list *a = (struct pri_list *)x;
-       struct pri_list *b = (struct pri_list *)y;
+        struct pri_list *a = CONST_DISCARD(struct pri_list *, x);
+       struct pri_list *b = CONST_DISCARD(struct pri_list *, y);
        if (a->pri > b->pri) return -1;
        if (a->pri == b->pri) return 0;
        return 1;