Ignore:
Timestamp:
May 26, 2009, 9:44:50 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.6

Location:
branches/samba-3.2.x/source/client
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/client/client.c

    r204 r228  
    43434343}
    43444344
     4345static bool finished;
     4346
    43454347/****************************************************************************
    43464348 Make sure we swallow keepalives during idle time.
     
    43894391                                  "the connection\n"));
    43904392
     4393                        finished = true;
     4394                        smb_readline_done();
    43914395                        if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
    43924396                                set_smb_read_error(&cli->smb_rw_error,
     
    44174421                unsigned char garbage[16];
    44184422                memset(garbage, 0xf0, sizeof(garbage));
    4419                 cli_echo(cli, 1, garbage, sizeof(garbage));
     4423                if (!cli_echo(cli, 1, garbage, sizeof(garbage))) {
     4424                        DEBUG(0, ("SMBecho failed. Maybe server has closed "
     4425                                  "the connection\n"));
     4426                        smb_readline_done();
     4427                        finished = true;
     4428                }
    44204429        }
    44214430}
     
    44294438        int rc = 0;
    44304439
    4431         while (1) {
     4440        while (!finished) {
    44324441                TALLOC_CTX *frame = talloc_stackframe();
    44334442                char *tok = NULL;
     
    46064615        fstrcat(server_name, name_type_hex);
    46074616
    4608         zero_addr(&ss);
     4617        zero_sockaddr(&ss);
    46094618        if (have_ip)
    46104619                ss = dest_ss;
  • branches/samba-3.2.x/source/client/mount.cifs.c

    r204 r228  
    4040#include <fcntl.h>
    4141#include <limits.h>
     42#include "mount.h"
    4243
    4344#define MOUNT_CIFS_VERSION_MAJOR "1"
    44 #define MOUNT_CIFS_VERSION_MINOR "11"
     45#define MOUNT_CIFS_VERSION_MINOR "12"
    4546
    4647#ifndef MOUNT_CIFS_VENDOR_SUFFIX
     
    5657 #endif /* _SAMBA_BUILD_ */
    5758#endif /* MOUNT_CIFS_VENDOR_SUFFIX */
     59
     60#ifdef _SAMBA_BUILD_
     61#include "include/config.h"
     62#endif
    5863
    5964#ifndef MS_MOVE
     
    95100/* like strncpy but does not 0 fill the buffer and always null
    96101 *    terminates. bufsize is the size of the destination buffer */
     102
     103#ifndef HAVE_STRLCPY
    97104static size_t strlcpy(char *d, const char *s, size_t bufsize)
    98105{
     
    105112        return ret;
    106113}
     114#endif
    107115
    108116/* like strncat but does not 0 fill the buffer and always null
    109117 *    terminates. bufsize is the length of the buffer, which should
    110118 *       be one more than the maximum resulting string length */
     119
     120#ifndef HAVE_STRLCAT
    111121static size_t strlcat(char *d, const char *s, size_t bufsize)
    112122{
     
    127137        return ret;
    128138}
     139#endif
    129140
    130141/* BB finish BB
     
    165176
    166177        SAFE_FREE(mountpassword);
    167         exit(1);
     178        exit(EX_USAGE);
    168179}
    169180
     
    224235                                        printf("mount.cifs failed due to malformed username in credentials file");
    225236                                        memset(line_buf,0,4096);
    226                                         exit(1);
     237                                        exit(EX_USAGE);
    227238                                } else {
    228239                                        got_user = 1;
     
    248259                                        printf("mount.cifs failed: password in credentials file too long\n");
    249260                                        memset(line_buf,0, 4096);
    250                                         exit(1);
     261                                        exit(EX_USAGE);
    251262                                } else {
    252263                                        if(mountpassword == NULL) {
     
    276287                                if(length > DOMAIN_SIZE) {
    277288                                        printf("mount.cifs failed: domain in credentials file too long\n");
    278                                         exit(1);
     289                                        exit(EX_USAGE);
    279290                                } else {
    280291                                        if(domain_name == NULL) {
     
    309320        if (mountpassword == NULL) {
    310321                printf("malloc failed\n");
    311                 exit(1);
     322                exit(EX_SYSERR);
    312323        }
    313324
     
    317328                        printf("mount.cifs failed. %s attempting to open password file %s\n",
    318329                                   strerror(errno),filename);
    319                         exit(1);
     330                        exit(EX_SYSERR);
    320331                }
    321332        }
     
    328339                        if(filename != NULL)
    329340                                close(file_descript);
    330                         exit(1);
     341                        exit(EX_SYSERR);
    331342                } else if(rc == 0) {
    332343                        if(mountpassword[0] == 0) {
     
    423434                                } else {
    424435                                        printf("username specified with no parameter\n");
     436                                        SAFE_FREE(out);
    425437                                        return 1;       /* needs_arg; */
    426438                                }
     
    455467                                } else {
    456468                                        printf("username too long\n");
     469                                        SAFE_FREE(out);
    457470                                        return 1;
    458471                                }
     
    470483                        } else {
    471484                                printf("password too long\n");
     485                                SAFE_FREE(out);
    472486                                return 1;
    473487                        }
     
    486500                        } else {
    487501                                printf("ip address too long\n");
     502                                SAFE_FREE(out);
    488503                                return 1;
    489504                        }
     
    493508                        if (!value || !*value) {
    494509                                printf("invalid path to network resource\n");
     510                                SAFE_FREE(out);
    495511                                return 1;  /* needs_arg; */
    496512                        } else if(strnlen(value,5) < 5) {
     
    507523                                } else if (strncmp(value, "\\\\", 2) != 0) {                       
    508524                                        printf("UNC Path does not begin with // or \\\\ \n");
     525                                        SAFE_FREE(out);
    509526                                        return 1;
    510527                                } else {
     
    516533                        } else {
    517534                                printf("CIFS: UNC name too long\n");
     535                                SAFE_FREE(out);
    518536                                return 1;
    519537                        }
     
    522540                        if (!value || !*value) {
    523541                                printf("CIFS: invalid domain name\n");
     542                                SAFE_FREE(out);
    524543                                return 1;       /* needs_arg; */
    525544                        }
     
    528547                        } else {
    529548                                printf("domain name too long\n");
     549                                SAFE_FREE(out);
    530550                                return 1;
    531551                        }
     
    536556                                        printf("error %d (%s) opening credential file %s\n",
    537557                                                rc, strerror(rc), value);
     558                                        SAFE_FREE(out);
    538559                                        return 1;
    539560                                }
    540561                        } else {
    541562                                printf("invalid credential file name specified\n");
     563                                SAFE_FREE(out);
    542564                                return 1;
    543565                        }
     
    550572                                        if (!(pw = getpwnam(value))) {
    551573                                                printf("bad user name \"%s\"\n", value);
    552                                                 exit(1);
     574                                                exit(EX_USAGE);
    553575                                        }
    554576                                        snprintf(user, sizeof(user), "%u", pw->pw_uid);
     
    566588                                        if (!(gr = getgrnam(value))) {
    567589                                                printf("bad group name \"%s\"\n", value);
    568                                                 exit(1);
     590                                                exit(EX_USAGE);
    569591                                        }
    570592                                        snprintf(group, sizeof(group), "%u", gr->gr_gid);
     
    578600                        if (!value || !*value) {
    579601                                printf ("Option '%s' requires a numerical argument\n", data);
     602                                SAFE_FREE(out);
    580603                                return 1;
    581604                        }
     
    592615                        if (!value || !*value) {
    593616                                printf ("Option '%s' requires a numerical argument\n", data);
     617                                SAFE_FREE(out);
    594618                                return 1;
    595619                        }
     
    661685                if (out == NULL) {
    662686                        perror("malloc");
    663                         exit(1);
     687                        exit(EX_SYSERR);
    664688                }
    665689
     
    686710                if (out == NULL) {
    687711                        perror("malloc");
    688                         exit(1);
     712                        exit(EX_SYSERR);
    689713                }
    690714
     
    702726                if (out == NULL) {
    703727                perror("malloc");
    704                         exit(1);
     728                        exit(EX_SYSERR);
    705729                }
    706730
     
    9831007
    9841008/* convert a string to uppercase. return false if the string
    985  * wasn't ASCII or was a NULL ptr */
     1009 * wasn't ASCII. Return success on a NULL ptr */
    9861010static int
    9871011uppercase_string(char *string)
    9881012{
    9891013        if (!string)
    990                 return 0;
     1014                return 1;
    9911015
    9921016        while (*string) {
     
    10371061        } else {
    10381062                mount_cifs_usage();
    1039                 exit(1);
     1063                exit(EX_USAGE);
    10401064        }
    10411065
     
    10541078                if (share_name == NULL) {
    10551079                        fprintf(stderr, "%s: %s", argv[0], strerror(ENOMEM));
    1056                         exit(1);
     1080                        exit(EX_SYSERR);
    10571081                }
    10581082                mountpoint = argv[2];
    10591083        } else {
    10601084                mount_cifs_usage();
    1061                 exit(1);
     1085                exit(EX_USAGE);
    10621086        }
    10631087
     
    10811105                case 'h':        /* help */
    10821106                        mount_cifs_usage ();
    1083                         exit(1);
     1107                        exit(EX_USAGE);
    10841108                case 'n':
    10851109                    ++nomtab;
     
    11351159                                if (*ep) {
    11361160                                        printf("bad uid value \"%s\"\n", optarg);
    1137                                         exit(1);
     1161                                        exit(EX_USAGE);
    11381162                                }
    11391163                        } else {
     
    11421166                                if (!(pw = getpwnam(optarg))) {
    11431167                                        printf("bad user name \"%s\"\n", optarg);
    1144                                         exit(1);
     1168                                        exit(EX_USAGE);
    11451169                                }
    11461170                                uid = pw->pw_uid;
     
    11551179                                if (*ep) {
    11561180                                        printf("bad gid value \"%s\"\n", optarg);
    1157                                         exit(1);
     1181                                        exit(EX_USAGE);
    11581182                                }
    11591183                        } else {
     
    11621186                                if (!(gr = getgrnam(optarg))) {
    11631187                                        printf("bad user name \"%s\"\n", optarg);
    1164                                         exit(1);
     1188                                        exit(EX_USAGE);
    11651189                                }
    11661190                                gid = gr->gr_gid;
     
    11921216                        printf("unknown mount option %c\n",c);
    11931217                        mount_cifs_usage();
    1194                         exit(1);
     1218                        exit(EX_USAGE);
    11951219                }
    11961220        }
     
    11981222        if((argc < 3) || (dev_name == NULL) || (mountpoint == NULL)) {
    11991223                mount_cifs_usage();
    1200                 exit(1);
     1224                exit(EX_USAGE);
    12011225        }
    12021226
     
    12151239
    12161240        if (orgoptions && parse_options(&orgoptions, &flags)) {
    1217                 rc = -1;
     1241                rc = EX_USAGE;
    12181242                goto mount_exit;
    12191243        }
     
    12211245        if((ipaddr == NULL) && (got_ip == 0)) {
    12221246                printf("No ip address specified and hostname not found\n");
    1223                 rc = -1;
     1247                rc = EX_USAGE;
    12241248                goto mount_exit;
    12251249        }
     
    12361260        if(chdir(mountpoint)) {
    12371261                printf("mount error: can not change directory into mount target %s\n",mountpoint);
    1238                 rc = -1;
     1262                rc = EX_USAGE;
    12391263                goto mount_exit;
    12401264        }
     
    12421266        if(stat (".", &statbuf)) {
    12431267                printf("mount error: mount point %s does not exist\n",mountpoint);
    1244                 rc = -1;
     1268                rc = EX_USAGE;
    12451269                goto mount_exit;
    12461270        }
     
    12481272        if (S_ISDIR(statbuf.st_mode) == 0) {
    12491273                printf("mount error: mount point %s is not a directory\n",mountpoint);
    1250                 rc = -1;
     1274                rc = EX_USAGE;
    12511275                goto mount_exit;
    12521276        }
     
    12611285                } else {
    12621286                        printf("mount error: permission denied or not superuser and mount.cifs not installed SUID\n");
    1263                         return -1;
     1287                        exit(EX_USAGE);
    12641288                }
    12651289        }
     
    12761300                if (!tmp_pass || !mountpassword) {
    12771301                        printf("Password not entered, exiting\n");
    1278                         return -1;
     1302                        exit(EX_USAGE);
    12791303                }
    12801304                strlcpy(mountpassword, tmp_pass, MOUNT_PASSWD_SIZE+1);
     
    12941318                printf("No server share name specified\n");
    12951319                printf("\nMounting the DFS root for server not implemented yet\n");
    1296                 exit(1);
     1320                exit(EX_USAGE);
    12971321        }
    12981322        if(user_name)
     
    13081332        if(options == NULL) {
    13091333                printf("Could not allocate memory for mount options\n");
    1310                 return -1;
     1334                exit(EX_SYSERR);
    13111335        }
    13121336
     
    13871411                }
    13881412                printf("Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)\n");
    1389                 rc = -1;
    1390                 goto mount_exit;
     1413                rc = EX_FAIL;
    13911414        } else {
     1415                atexit(unlock_mtab);
     1416                rc = lock_mtab();
     1417                if (rc) {
     1418                        printf("cannot lock mtab");
     1419                        goto mount_exit;
     1420                }
    13921421                pmntfile = setmntent(MOUNTED, "a+");
    1393                 if(pmntfile) {
    1394                         mountent.mnt_fsname = dev_name;
    1395                         mountent.mnt_dir = mountpoint;
    1396                         mountent.mnt_type = CONST_DISCARD(char *,"cifs");
    1397                         mountent.mnt_opts = (char *)malloc(220);
    1398                         if(mountent.mnt_opts) {
    1399                                 char * mount_user = getusername();
    1400                                 memset(mountent.mnt_opts,0,200);
    1401                                 if(flags & MS_RDONLY)
    1402                                         strlcat(mountent.mnt_opts,"ro",220);
    1403                                 else
    1404                                         strlcat(mountent.mnt_opts,"rw",220);
    1405                                 if(flags & MS_MANDLOCK)
    1406                                         strlcat(mountent.mnt_opts,",mand",220);
    1407                                 if(flags & MS_NOEXEC)
    1408                                         strlcat(mountent.mnt_opts,",noexec",220);
    1409                                 if(flags & MS_NOSUID)
    1410                                         strlcat(mountent.mnt_opts,",nosuid",220);
    1411                                 if(flags & MS_NODEV)
    1412                                         strlcat(mountent.mnt_opts,",nodev",220);
    1413                                 if(flags & MS_SYNCHRONOUS)
    1414                                         strlcat(mountent.mnt_opts,",synch",220);
    1415                                 if(mount_user) {
    1416                                         if(getuid() != 0) {
    1417                                                 strlcat(mountent.mnt_opts,",user=",220);
    1418                                                 strlcat(mountent.mnt_opts,mount_user,220);
    1419                                         }
    1420                                         /* free(mount_user); do not free static mem */
    1421                                 }
    1422                         }
    1423                         mountent.mnt_freq = 0;
    1424                         mountent.mnt_passno = 0;
    1425                         rc = addmntent(pmntfile,&mountent);
    1426                         endmntent(pmntfile);
    1427                         SAFE_FREE(mountent.mnt_opts);
    1428                 } else {
    1429                     printf("could not update mount table\n");
    1430                 }
    1431         }
    1432         rc = 0;
     1422                if (!pmntfile) {
     1423                        printf("could not update mount table\n");
     1424                        unlock_mtab();
     1425                        rc = EX_FILEIO;
     1426                        goto mount_exit;
     1427                }
     1428                mountent.mnt_fsname = dev_name;
     1429                mountent.mnt_dir = mountpoint;
     1430                mountent.mnt_type = CONST_DISCARD(char *,"cifs");
     1431                mountent.mnt_opts = (char *)malloc(220);
     1432                if(mountent.mnt_opts) {
     1433                        char * mount_user = getusername();
     1434                        memset(mountent.mnt_opts,0,200);
     1435                        if(flags & MS_RDONLY)
     1436                                strlcat(mountent.mnt_opts,"ro",220);
     1437                        else
     1438                                strlcat(mountent.mnt_opts,"rw",220);
     1439                        if(flags & MS_MANDLOCK)
     1440                                strlcat(mountent.mnt_opts,",mand",220);
     1441                        if(flags & MS_NOEXEC)
     1442                                strlcat(mountent.mnt_opts,",noexec",220);
     1443                        if(flags & MS_NOSUID)
     1444                                strlcat(mountent.mnt_opts,",nosuid",220);
     1445                        if(flags & MS_NODEV)
     1446                                strlcat(mountent.mnt_opts,",nodev",220);
     1447                        if(flags & MS_SYNCHRONOUS)
     1448                                strlcat(mountent.mnt_opts,",sync",220);
     1449                        if(mount_user) {
     1450                                if(getuid() != 0) {
     1451                                        strlcat(mountent.mnt_opts,
     1452                                                ",user=", 220);
     1453                                        strlcat(mountent.mnt_opts,
     1454                                                mount_user, 220);
     1455                                }
     1456                        }
     1457                }
     1458                mountent.mnt_freq = 0;
     1459                mountent.mnt_passno = 0;
     1460                rc = addmntent(pmntfile,&mountent);
     1461                endmntent(pmntfile);
     1462                unlock_mtab();
     1463                SAFE_FREE(mountent.mnt_opts);
     1464                if (rc)
     1465                        rc = EX_FILEIO;
     1466        }
    14331467mount_exit:
    14341468        if(mountpassword) {
     
    14421476        SAFE_FREE(resolved_path);
    14431477        SAFE_FREE(share_name);
    1444         return rc;
     1478        exit(rc);
    14451479}
  • branches/samba-3.2.x/source/client/umount.cifs.c

    r133 r228  
    3434#include <string.h>
    3535#include <mntent.h>
     36#include "mount.h"
    3637
    3738#define UNMOUNT_CIFS_VERSION_MAJOR "0"
    38 #define UNMOUNT_CIFS_VERSION_MINOR "5"
     39#define UNMOUNT_CIFS_VERSION_MINOR "6"
    3940
    4041#ifndef UNMOUNT_CIFS_VENDOR_SUFFIX
     
    138139}
    139140
    140 static int lock_mtab(void)
    141 {
    142         int rc;
    143        
    144         rc = mknod(MOUNTED_LOCK , 0600, 0);
    145         if(rc == -1)
    146                 printf("\ngetting lock file %s failed with %s\n",MOUNTED_LOCK,
    147                                 strerror(errno));
    148                
    149         return rc;     
    150        
    151 }
    152 
    153 static void unlock_mtab(void)
    154 {
    155         unlink(MOUNTED_LOCK);   
    156 }
    157 
    158141static int remove_from_mtab(char * mountpoint)
    159142{
     
    169152        /* Do we first need to check if it is writable? */
    170153
     154        atexit(unlock_mtab);
    171155        if (lock_mtab()) {
    172156                printf("Mount table locked\n");
Note: See TracChangeset for help on using the changeset viewer.