[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Sun Jul 4 03:44:54 MDT 2010
The branch, master has been updated
via 9e3fc22... s3: Fix bug 7338, smbget skips leading slash when using a custom outputfile
via 285176c... s3: Fix some nonempty blank lines
from 8c0fbc4... s3: Fix bug 7336: Enable idmap_passdb module build as shared
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 9e3fc22c600e3da150e96ac5f7823835c8be4333
Author: Volker Lendecke <vl at samba.org>
Date: Sun Jul 4 11:32:50 2010 +0200
s3: Fix bug 7338, smbget skips leading slash when using a custom outputfile
commit 285176cbc9e77c6f70aabbc33bae37d35ffe808a
Author: Volker Lendecke <vl at samba.org>
Date: Sun Jul 4 11:02:21 2010 +0200
s3: Fix some nonempty blank lines
-----------------------------------------------------------------------
Summary of changes:
source3/utils/smbget.c | 42 ++++++++++++++++++++++++++----------------
1 files changed, 26 insertions(+), 16 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index 4dd573a..8b88a0f 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@@ -49,7 +49,8 @@ static const char *username = NULL, *password = NULL, *workgroup = NULL;
static int nonprompt = 0, quiet = 0, dots = 0, keep_permissions = 0, verbose = 0, send_stdout = 0;
static int blocksize = SMB_DEFAULT_BLOCKSIZE;
-static int smb_download_file(const char *base, const char *name, int recursive, int resume, char *outfile);
+static int smb_download_file(const char *base, const char *name, int recursive,
+ int resume, int toplevel, char *outfile);
static int get_num_cols(void)
{
@@ -135,14 +136,17 @@ static int smb_download_dir(const char *base, const char *name, int resume)
/* List files in directory and call smb_download_file on them */
dirhandle = smbc_opendir(path);
if(dirhandle < 1) {
- if(errno == ENOTDIR) return smb_download_file(base, name, 1, resume, NULL);
+ if (errno == ENOTDIR) {
+ return smb_download_file(base, name, 1, resume,
+ 0, NULL);
+ }
fprintf(stderr, "Can't open directory %s: %s\n", path, strerror(errno));
return 1;
}
while(*relname == '/')relname++;
mkdir(relname, 0755);
-
+
tmpname = SMB_STRDUP(name);
while((dirent = smbc_readdir(dirhandle))) {
@@ -165,7 +169,8 @@ static int smb_download_dir(const char *base, const char *name, int resume)
break;
case SMBC_FILE:
- ret = smb_download_file(base, newname, 1, resume, NULL);
+ ret = smb_download_file(base, newname, 1, resume, 0,
+ NULL);
break;
case SMBC_FILE_SHARE:
@@ -179,7 +184,7 @@ static int smb_download_dir(const char *base, const char *name, int resume)
case SMBC_COMMS_SHARE:
if(!quiet)printf("Ignoring comms share %s\n", dirent->name);
break;
-
+
case SMBC_IPC_SHARE:
if(!quiet)printf("Ignoring ipc$ share %s\n", dirent->name);
break;
@@ -198,7 +203,7 @@ static int smb_download_dir(const char *base, const char *name, int resume)
smbc_closedir(dirhandle);
return 1;
}
-
+
if(chmod(relname, remotestat.st_mode) < 0) {
fprintf(stderr, "Unable to change mode of local dir %s to %o\n", relname,
(unsigned int)remotestat.st_mode);
@@ -247,7 +252,7 @@ static void print_progress(const char *name, time_t start, time_t now, off_t sta
if (len == -1) {
return;
}
-
+
if(columns) {
int required = strlen(name), available = columns - len - strlen("[] ");
if(required > available) {
@@ -266,7 +271,9 @@ static void print_progress(const char *name, time_t start, time_t now, off_t sta
/* Return 1 on error, 0 on success. */
-static int smb_download_file(const char *base, const char *name, int recursive, int resume, char *outfile) {
+static int smb_download_file(const char *base, const char *name, int recursive,
+ int resume, int toplevel, char *outfile)
+{
int remotehandle, localhandle;
time_t start_time = time(NULL);
const char *newpath;
@@ -277,7 +284,7 @@ static int smb_download_file(const char *base, const char *name, int recursive,
struct stat localstat, remotestat;
snprintf(path, SMB_MAXPATHLEN-1, "%s%s%s", base, (*base && *name && name[0] != '/' && base[strlen(base)-1] != '/')?"/":"", name);
-
+
remotehandle = smbc_open(path, O_RDONLY, 0755);
if(remotehandle < 0) {
@@ -322,8 +329,10 @@ static int smb_download_file(const char *base, const char *name, int recursive,
if(newpath)newpath++; else newpath = base;
} else newpath = name;
- if(newpath[0] == '/')newpath++;
-
+ if (!toplevel && (newpath[0] == '/')) {
+ newpath++;
+ }
+
/* Open local file according to the mode */
if(update) {
/* if it is up-to-date, skip */
@@ -350,7 +359,7 @@ static int smb_download_file(const char *base, const char *name, int recursive,
smbc_close(remotehandle);
return 1;
}
-
+
if (fstat(localhandle, &localstat) != 0) {
fprintf(stderr, "Can't fstat %s: %s\n", newpath, strerror(errno));
smbc_close(remotehandle);
@@ -652,14 +661,15 @@ int main(int argc, const char **argv)
CONST_DISCARD(char *, "smb_encrypt_level"),
"require");
}
-
+
columns = get_num_cols();
total_start_time = time(NULL);
while ( (file = poptGetArg(pc)) ) {
if (!recursive)
- ret = smb_download_file(file, "", recursive, resume, outputfile);
+ ret = smb_download_file(file, "", recursive, resume,
+ 1, outputfile);
else
ret = smb_download_dir(file, "", resume);
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list