r6392: - Fixes bug 2564: when smbc_opendir() was called with a file rather than
authorDerrell Lipman <derrell@samba.org>
Tue, 19 Apr 2005 19:23:49 +0000 (19:23 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:56:40 +0000 (10:56 -0500)
  a directory, the errno returned could end up as ENOENT rather than ENOTDIR.

- Fixes some compiler warnings which showed up on IRIX, as reported by
  James Peach.
(This used to be commit 615a62b21f8d2f7f97bde2f166ddd6849d39b95c)

source3/libsmb/clifile.c
source3/libsmb/clikrb5.c
source3/libsmb/clirap2.c
source3/libsmb/libsmbclient.c
source3/libsmb/trustdom_cache.c
source3/libsmb/trusts_util.c

index 93492ec08229654b38ca5502321e31689a61a3dd..5304f5d8cf54f2645941d3d1055476bbdbc5d663 100644 (file)
@@ -266,8 +266,8 @@ BOOL cli_unix_stat(struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbu
        sbuf->st_ctime = interpret_long_date(rdata + 16);    /* time of last change */
        sbuf->st_atime = interpret_long_date(rdata + 24);    /* time of last access */
        sbuf->st_mtime = interpret_long_date(rdata + 32);    /* time of last modification */
-       sbuf->st_uid = IVAL(rdata,40);      /* user ID of owner */
-       sbuf->st_gid = IVAL(rdata,48);      /* group ID of owner */
+       sbuf->st_uid = (uid_t) IVAL(rdata,40);      /* user ID of owner */
+       sbuf->st_gid = (gid_t) IVAL(rdata,48);      /* group ID of owner */
        sbuf->st_mode |= unix_filetype_from_wire(IVAL(rdata, 56));
 #if defined(HAVE_MAKEDEV)
        {
index c35b53a9dd8563474042065de5364a11b5ab337b..43252b94d8352a26dfa7c5cc08fd9585f1672b5f 100644 (file)
@@ -396,7 +396,7 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context,
                /* cope with ticket being in the future due to clock skew */
                if ((unsigned)credsp->times.starttime > time(NULL)) {
                        time_t t = time(NULL);
-                       int time_offset =(unsigned)credsp->times.starttime-t;
+                       int time_offset =(int)((unsigned)credsp->times.starttime-t);
                        DEBUG(4,("ads_krb5_mk_req: Advancing clock by %d seconds to cope with clock skew\n", time_offset));
                        krb5_set_real_time(context, t + time_offset + 1, 0);
                }
@@ -405,7 +405,7 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context,
                        creds_ready = True;
        }
 
-       DEBUG(10,("ads_krb5_mk_req: Ticket (%s) in ccache (%s) is valid until: (%s - %d)\n",
+       DEBUG(10,("ads_krb5_mk_req: Ticket (%s) in ccache (%s) is valid until: (%s - %u)\n",
                  principal, krb5_cc_default_name(context),
                  http_timestring((unsigned)credsp->times.endtime), 
                  (unsigned)credsp->times.endtime));
index d8a85195502862b3ff70b2a89f56981f26d8cd30..b15ee1a63e2583eaac71997d7c3dd571860a33e1 100644 (file)
@@ -369,10 +369,9 @@ int cli_RNetGroupEnum0(struct cli_state *cli,
 
   if (rdata) {
     if (res == 0 || res == ERRmoredata) {
-      int i, converter, count;
+      int i, count;
 
-      p = rparam + WORDSIZE; /* skip result */
-      GETWORD(p, converter);
+      p = rparam + WORDSIZE + WORDSIZE; /* skip result and converter */
       GETWORD(p, count);
 
       for (i=0,p=rdata;i<count;i++) {
@@ -543,10 +542,9 @@ int cli_NetGroupGetUsers(struct cli_state * cli, const char *group_name, void (*
   }
   if (rdata) {
     if (res == 0 || res == ERRmoredata) {
-      int i, converter, count;
+      int i, count;
       fstring username;
-      p = rparam +WORDSIZE;
-      GETWORD(p, converter);
+      p = rparam + WORDSIZE + WORDSIZE;
       GETWORD(p, count);
 
       for (i=0,p=rdata; i<count; i++) {
@@ -598,10 +596,9 @@ int cli_NetUserGetGroups(struct cli_state * cli, const char *user_name, void (*f
   }
   if (rdata) {
     if (res == 0 || res == ERRmoredata) {
-      int i, converter, count;
+      int i, count;
       fstring groupname;
-      p = rparam +WORDSIZE;
-      GETWORD(p, converter);
+      p = rparam + WORDSIZE + WORDSIZE;
       GETWORD(p, count);
 
       for (i=0,p=rdata; i<count; i++) {
@@ -800,7 +797,6 @@ int cli_RNetUserEnum(struct cli_state *cli, void (*fn)(const char *, const char
       char username[RAP_USERNAME_LEN];
       char userpw[RAP_UPASSWD_LEN];
       pstring comment, homedir, logonscript;
-      int pwage, priv, flags;
 
       p = rparam + WORDSIZE; /* skip result */
       GETWORD(p, converter);
@@ -810,11 +806,11 @@ int cli_RNetUserEnum(struct cli_state *cli, void (*fn)(const char *, const char
         GETSTRINGF(p, username, RAP_USERNAME_LEN);
         p++; /* pad byte */
         GETSTRINGF(p, userpw, RAP_UPASSWD_LEN);
-        GETDWORD(p, pwage); /* password age */
-        GETWORD(p, priv); /* 0=guest, 1=user, 2=admin */
+        p += DWORDSIZE; /* skip password age */
+        p += WORDSIZE;  /* skip priv: 0=guest, 1=user, 2=admin */
         GETSTRINGP(p, homedir, rdata, converter);
         GETSTRINGP(p, comment, rdata, converter);
-        GETWORD(p, flags);
+        p += WORDSIZE;  /* skip flags */
         GETSTRINGP(p, logonscript, rdata, converter);
 
         fn(username, comment, homedir, logonscript, cli);
@@ -868,11 +864,10 @@ int cli_RNetUserEnum0(struct cli_state *cli,
   }
   if (rdata) {
     if (res == 0 || res == ERRmoredata) {
-      int i, converter, count;
+      int i, count;
       char username[RAP_USERNAME_LEN];
 
-      p = rparam + WORDSIZE; /* skip result */
-      GETWORD(p, converter);
+      p = rparam + WORDSIZE + WORDSIZE; /* skip result and converter */
       GETWORD(p, count);
 
       for (i=0,p=rdata;i<count;i++) {
@@ -1473,10 +1468,9 @@ BOOL cli_ns_check_server_type(struct cli_state *cli, char *workgroup, uint32 sty
     cli->rap_error = res;
 
     if (res == 0 || res == ERRmoredata) {
-      int i, converter, count;
+      int i, count;
 
-      p = rparam + WORDSIZE;
-      GETWORD(p, converter);
+      p = rparam + WORDSIZE + WORDSIZE;
       GETWORD(p, count);
 
       p = rdata;
@@ -1798,10 +1792,9 @@ int cli_RNetServiceEnum(struct cli_state *cli, void (*fn)(const char *, const ch
 
   if (rdata) {
     if (res == 0 || res == ERRmoredata) {
-      int i, converter, count;
+      int i, count;
 
-      p = rparam + WORDSIZE; /* skip result */
-      GETWORD(p, converter);
+      p = rparam + WORDSIZE + WORDSIZE; /* skip result and converter */
       GETWORD(p, count);
 
       for (i=0,p=rdata;i<count;i++) {
@@ -1943,14 +1936,14 @@ int cli_NetSessionGetInfo(struct cli_state *cli, const char *workstation, void (
     res = GETRES(rparam);
     
     if (res == 0 || res == ERRmoredata) {
-      int rsize, converter;
+      int converter;
       pstring wsname, username, clitype_name;
       uint16  num_conns, num_opens, num_users;
       unsigned int    sess_time, idle_time, user_flags;
 
       p = rparam + WORDSIZE;
       GETWORD(p, converter);
-      GETWORD(p, rsize);
+      p += WORDSIZE;            /* skip rsize */
 
       p = rdata;
       GETSTRINGP(p, wsname, rdata, converter);
index 3e8e604ab11488380f78c07e12aa8e66e7bd970e..791427f2497df0c185959058b636ffaf57387837 100644 (file)
@@ -646,13 +646,10 @@ SMBCSRV *smbc_server(SMBCCTX *context,
          * Force use of port 139 for first try if share is $IPC, empty, or
          * null, so browse lists can work
          */
-        if (share == NULL || *share == '\0' || strcmp(share, "IPC$") == 0)
-        {
+        if (share == NULL || *share == '\0' || strcmp(share, "IPC$") == 0) {
                 port_try_first = 139;
                 port_try_next = 445;
-        }
-        else
-        {
+        } else {
                 port_try_first = 445;
                 port_try_next = 139;
         }
@@ -1905,6 +1902,8 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname)
        fstring server, share, user, password, options;
        pstring workgroup;
        pstring path;
+        uint16 mode;
+        char *p;
        SMBCSRV *srv  = NULL;
        SMBCFILE *dir = NULL;
        struct in_addr rem_ip;
@@ -2197,6 +2196,7 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname)
 
                        /* Now, list the files ... */
 
+                        p = path + strlen(path);
                        pstrcat(path, "\\*");
 
                        if (cli_list(&srv->cli, path, aDIR | aSYSTEM | aHIDDEN, dir_list_fn, 
@@ -2207,6 +2207,27 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname)
                                        SAFE_FREE(dir);
                                }
                                errno = smbc_errno(context, &srv->cli);
+
+                                if (errno == EINVAL) {
+                                    /*
+                                     * See if they asked to opendir something
+                                     * other than a directory.  If so, the
+                                     * converted error value we got would have
+                                     * been EINVAL rather than ENOTDIR.
+                                     */
+                                    *p = '\0'; /* restore original path */
+
+                                    if (smbc_getatr(context, srv, path,
+                                                    &mode, NULL,
+                                                    NULL, NULL, NULL,
+                                                    NULL) &&
+                                        ! IS_DOS_DIR(mode)) {
+
+                                        /* It is.  Correct the error value */
+                                        errno = ENOTDIR;
+                                    }
+                                }
+
                                return NULL;
 
                        }
index e63acd18c4f14ac5c5faf7289951882fde7ef0cd..8c5fb4d907135e2cc9ef5460deade29e9cece6cb 100644 (file)
@@ -320,7 +320,7 @@ void update_trustdom_cache( void )
        if ( (last_check = trustdom_cache_fetch_timestamp()) == 0 ) 
                trustdom_cache_store_timestamp(0, now+TRUSTDOM_UPDATE_INTERVAL);
 
-       time_diff = now - last_check;
+       time_diff = (int) (now - last_check);
        
        if ( (time_diff > 0) && (time_diff < TRUSTDOM_UPDATE_INTERVAL) ) {
                DEBUG(10,("update_trustdom_cache: not time to update trustdom_cache yet\n"));
index b420e4fa08168b77d4586ea65baa1817659c1787..aab0d7d151745887958fee39912b9169cfadb848 100644 (file)
@@ -104,11 +104,8 @@ NTSTATUS trust_pw_find_change_and_store_it(struct cli_state *cli,
                                           const char *domain) 
 {
        unsigned char old_trust_passwd_hash[16];
-       char *up_domain;
        uint32 sec_channel_type = 0;
 
-       up_domain = talloc_strdup(mem_ctx, domain);
-
        if (!secrets_fetch_trust_account_password(domain,
                                                  old_trust_passwd_hash, 
                                                  NULL, &sec_channel_type)) {