svn commit: samba r9716 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-08-28 22:00:28 + (Sun, 28 Aug 2005) New Revision: 9716 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=9716 Log: Now using the correct mode variable in mget. Fixed up recursion/directory handling in mget. -Kalim Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-28 21:46:46 UTC (rev 9715) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-28 22:00:28 UTC (rev 9716) @@ -666,7 +666,7 @@ { if (smbc_stat(dentname, stat) 0) { -d_printf( %s - error: %s\n, dent-name, strerror(errno)); +d_printf( %s - stat error: %s\n, dent-name, strerror(errno)); } else { @@ -1047,7 +1047,7 @@ if (strequal(name,.) || strequal(name,..)) return; -if (S_ISDIR(mode)) +if (S_ISDIR(st-st_mode)) slprintf(quest,sizeof(pstring)-1, Get directory %s%s? , cur_dir, name); else slprintf(quest,sizeof(pstring)-1, Get file %s%s? , cur_dir, name); @@ -1055,7 +1055,7 @@ if (prompt !yesno(quest)) return; - if (!S_ISDIR(mode)) { + if (!S_ISDIR(st-st_mode)) { pstrcpy(rname,smb:); pstrcat(rname,service); pstrcat(rname,cur_dir); @@ -1066,7 +1066,7 @@ /* handle directories */ /* TODO: clean this code up for recursive calls */ - /*pstrcpy(saved_curdir,cur_dir); + pstrcpy(saved_curdir,cur_dir); pstrcat(cur_dir,name); pstrcat(cur_dir,/); @@ -1088,12 +1088,15 @@ return; } - pstrcpy(mget_mask,cur_dir); +pstrcpy(mget_mask,smb:); +pstrcat(mget_mask,service); + pstrcat(mget_mask,cur_dir); pstrcat(mget_mask,*); - tool_list(mget_mask, mode, do_mget, False, True); +/*d_printf(Calling with mask: %s\n, mget_mask);*/ + tool_list(mget_mask, mode, do_mget, recurse, recurse); chdir(..); - pstrcpy(cur_dir,saved_curdir);*/ + pstrcpy(cur_dir,saved_curdir); } / @@ -1167,7 +1170,7 @@ pstrcat(mget_mask,p); /* TODO: enable directories on calls to tool_list once recursion is worked out */ - tool_list(mget_mask, mode, do_mget, recurse, False); + tool_list(mget_mask, mode, do_mget, recurse, recurse); } if (!*mget_mask) { @@ -1177,7 +1180,7 @@ if(mget_mask[strlen(mget_mask)-1]!='/') pstrcat(mget_mask,/); pstrcat(mget_mask,*); - tool_list(mget_mask, mode, do_mget, recurse, False); + tool_list(mget_mask, mode, do_mget, recurse, recurse); } return 0;
svn commit: samba r9726 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-08-29 01:27:39 + (Mon, 29 Aug 2005) New Revision: 9726 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=9726 Log: Fixed a bug with command line workgroup being overwritten by call to smbc_init(). -Kalim Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-29 01:17:20 UTC (rev 9725) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-29 01:27:39 UTC (rev 9726) @@ -40,6 +40,7 @@ static pstring service; static pstring desthost; static pstring username; +static pstring workgroup; static pstring calling_name; static BOOL grepable=False; static char *cmdstr = NULL; @@ -132,9 +133,9 @@ } else { -d_printf(Workgroup: %s\n, lp_workgroup()); -strncpy(pWorkgroup, lp_workgroup(), maxLenWorkgroup - 1); -strncpy(authWorkgroup, lp_workgroup(), maxLenWorkgroup - 1); +d_printf(Workgroup: %s\n, workgroup); +strncpy(pWorkgroup, workgroup, maxLenWorkgroup - 1); +strncpy(authWorkgroup, workgroup, maxLenWorkgroup - 1); d_printf(Username: %s\n, username); strncpy(pUsername, username, maxLenUsername - 1); @@ -3662,6 +3663,7 @@ if ( strlen(new_workgroup) != 0 ) set_global_myworkgroup( new_workgroup ); +pstrcpy(workgroup, lp_workgroup()); if ( strlen(calling_name) != 0 ) set_global_myname( calling_name );
svn commit: samba r9667 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-08-26 21:18:39 + (Fri, 26 Aug 2005) New Revision: 9667 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=9667 Log: Changed the way cmd_mput checks if a directory exists. (Thanks to derrell for catching that). -Kalim Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-26 20:29:01 UTC (rev 9666) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-26 21:18:39 UTC (rev 9667) @@ -1663,25 +1663,25 @@ if (!seek_list(temp_list, lname)) break; } else { /* Yes */ -int dh; SAFE_FREE(rname); if(asprintf(rname, smb:%s%s%s, service, cur_dir, lname) 0) break; /*dos_format(rname);*/ /* test if the directory exists by opening it */ -if (!((dh=smbc_opendir(rname)) 0)) { +/*if (!((dh=smbc_opendir(rname)) 0)) { smbc_closedir(dh); continue; +}*/ +/* test if the directory exists by making it */ +ret = smbc_mkdir(rname, 755); +if ((ret != 0) (errno != EEXIST)) +{ +d_printf(Error: %s. Unable to open or create dir %s, skipping...\n, strerror(errno), rname); +/* Skip the directory */ +lname[strlen(lname)-1] = '/'; +if (!seek_list(temp_list, lname)) +break; } -/* directory does not exist, try making it */ -if (!(smbc_mkdir(rname, 755) 0)) -continue; - -d_printf(Unable to open or create dir, skipping...\n); -/* Skip the directory */ -lname[strlen(lname)-1] = '/'; -if (!seek_list(temp_list, lname)) -break; } continue; } else {
svn commit: samba r9629 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-08-26 04:23:41 + (Fri, 26 Aug 2005) New Revision: 9629 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=9629 Log: Patched up and enabled mput command. Minor fixes to put command. -Kalim Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-26 03:40:24 UTC (rev 9628) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-26 04:23:41 UTC (rev 9629) @@ -961,7 +961,7 @@ } if (nread + start stat.st_size) { - DEBUG (0, (Short read when getting file %s. Only got %ld bytes.\n, rname, (long)nread)); + DEBUG (1, (Short read when getting file %s. Only got %ld bytes.\n, rname, (long)nread)); rc = 1; } @@ -1337,6 +1337,11 @@ start = stat.st_size; } else { fnum = smbc_creat(rname, 0644); +if (fnum 0) +{ +d_printf(%s trying to create remote file %s\n, strerror(errno), rname); +return 1; +} } /* allow files to be piped into smbclient @@ -1658,17 +1663,25 @@ if (!seek_list(temp_list, lname)) break; } else { /* Yes */ - SAFE_FREE(rname); - if(asprintf(rname, %s%s, cur_dir, lname) 0) break; - dos_format(rname); - if (!cli_chkpath(cli, rname) - !do_mkdir(rname)) { - DEBUG (0, (Unable to make dir, skipping...)); - /* Skip the directory */ - lname[strlen(lname)-1] = '/'; - if (!seek_list(temp_list, lname)) - break; - } +int dh; +SAFE_FREE(rname); + if(asprintf(rname, smb:%s%s%s, service, cur_dir, lname) 0) break; + /*dos_format(rname);*/ + +/* test if the directory exists by opening it */ +if (!((dh=smbc_opendir(rname)) 0)) { +smbc_closedir(dh); +continue; +} +/* directory does not exist, try making it */ +if (!(smbc_mkdir(rname, 755) 0)) +continue; + +d_printf(Unable to open or create dir, skipping...\n); +/* Skip the directory */ +lname[strlen(lname)-1] = '/'; +if (!seek_list(temp_list, lname)) +break; } continue; } else { @@ -1679,11 +1692,10 @@ /* Yes */ SAFE_FREE(rname); - if (asprintf(rname, %s%s, cur_dir, lname) 0) break; + if (asprintf(rname, smb:%s%s%s, service, cur_dir, lname) 0) break; } - dos_format(rname); - +/*d_printf(PUT: rname: %s, lname: %s\n, rname, lname);*/ do_put(rname, lname, False); } free_file_list(file_list); @@ -2906,7 +2918,7 @@ /* {mget,cmd_mget,mask get all the matching files,{COMPL_REMOTE,COMPL_NONE}}, */ {mkdir,cmd_mkdir,directory make a directory,{COMPL_NONE,COMPL_NONE}}, /* {more,cmd_more,remote name view a remote file with your pager,{COMPL_REMOTE,COMPL_NONE}}, */ -/* {mput,cmd_mput,mask put all matching files,{COMPL_REMOTE,COMPL_NONE}}, */ + {mput,cmd_mput,mask put all matching files,{COMPL_REMOTE,COMPL_NONE}}, {newer,cmd_newer,file only mget files newer than the specified local file,{COMPL_LOCAL,COMPL_NONE}}, /* {open,cmd_open,mask open a file,{COMPL_REMOTE,COMPL_NONE}}, */ /* {print,cmd_print,file name print a file,{COMPL_NONE,COMPL_NONE}}, */
svn commit: samba r9596 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-08-24 22:07:55 + (Wed, 24 Aug 2005) New Revision: 9596 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=9596 Log: Introduced tool_list() - a replacement for do_list()/cli_list() that uses the libsmbclient library instead of cli_* calls. Rewrote ls/dir command to use the tool_list code. Wrote get command internals and enabled cmd_get. Minimal path parsing is done right now. -Kalim Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Sorry, the patch is too large (495 lines) to include; please use WebSVN to see it! WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=9596
svn commit: samba r9605 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-08-25 02:55:54 + (Thu, 25 Aug 2005) New Revision: 9605 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=9605 Log: Wrote the core of the 'put' command and enabled cmd_put. -Kalim Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-25 02:33:08 UTC (rev 9604) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-25 02:55:54 UTC (rev 9605) @@ -933,6 +933,7 @@ if (newhandle) close(handle); smbc_close(fnum); +SAFE_FREE(data); return 1; } while (1) { @@ -944,6 +945,7 @@ if (newhandle) close(handle); smbc_close(fnum); +SAFE_FREE(data); return 1; } if (n == 0) @@ -1315,33 +1317,27 @@ int maxwrite = io_bufsize; int rc = 0; struct timeval tp_start; - struct cli_state *targetcli; - pstring targetname; +struct stat stat; - if ( !cli_resolve_path( , cli, rname, targetcli, targetname ) ) { - d_printf(Failed to open %s: %s\n, rname, cli_errstr(cli)); - return 1; - } - GetTimeOfDay(tp_start); if (reput) { - fnum = cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE); - if (fnum = 0) { - if (!cli_qfileinfo(targetcli, fnum, NULL, start, NULL, NULL, NULL, NULL, NULL) - !cli_getattrE(targetcli, fnum, NULL, start, NULL, NULL, NULL)) { - d_printf(getattrib: %s\n,cli_errstr(cli)); - return 1; - } - } +fnum = smbc_open(rname, O_RDWR|O_CREAT, 0644); +if (fnum 0) +{ +d_printf(%s opening remote file %s\n, strerror(errno), rname); +return 1; +} +if (smbc_fstat(fnum, stat) 0) +{ +d_printf(%s trying to stat remote file %s\n, strerror(errno), rname); +smbc_close(fnum); +return 1; +} +start = stat.st_size; } else { - fnum = cli_open(targetcli, targetname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE); +fnum = smbc_creat(rname, 0644); } - - if (fnum == -1) { - d_printf(%s opening remote file %s\n,cli_errstr(targetcli),rname); - return 1; - } /* allow files to be piped into smbclient jdblair 24.jun.98 @@ -1356,6 +1352,8 @@ if (f reput) { if (x_tseek(f, start, SEEK_SET) == -1) { d_printf(Error seeking local file\n); +smbc_close(fnum); +x_fclose(f); return 1; } } @@ -1363,17 +1361,30 @@ if (!f) { d_printf(Error opening local file %s\n,lname); +smbc_close(fnum); return 1; } - DEBUG(1,(putting file %s as %s ,lname, -rname)); + DEBUG(1,(putting file %s as %s ,lname,rname)); buf = (char *)SMB_MALLOC(maxwrite); if (!buf) { d_printf(ERROR: Not enough memory!\n); +smbc_close(fnum); +if (f != x_stdin) +x_fclose(f); return 1; } + +if (smbc_lseek(fnum, start, SEEK_SET) 0) +{ +d_printf(%s trying to lseek remote file %s\n, strerror(errno), rname); +if (f != x_stdin) +x_fclose(f); +smbc_close(fnum); +SAFE_FREE(buf); +return 1; +} while (!x_feof(f)) { int n = maxwrite; int ret; @@ -1387,10 +1398,10 @@ break; } - ret = cli_write(targetcli, fnum, 0, buf, nread + start, n); +ret = smbc_write(fnum, buf, n); if (n != ret) { - d_printf(Error writing file: %s\n, cli_errstr(cli)); + d_printf(Error writing file: %s\n, strerror(errno)); rc = 1; break; } @@ -1398,9 +1409,10 @@ nread += n; } - if (!cli_close(targetcli, fnum)) { - d_printf(%s closing remote file %s\n,cli_errstr(cli),rname); - x_fclose(f); + if (smbc_close(fnum) 0) { + d_printf(%s closing remote file %s\n,strerror(errno),rname); +if (f != x_stdin) +x_fclose(f); SAFE_FREE(buf); return 1; } @@ -1447,8 +1459,9 @@ pstring buf; char *p=buf; - pstrcpy(rname,cur_dir
svn commit: samba r9380 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-08-18 06:50:58 + (Thu, 18 Aug 2005) New Revision: 9380 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=9380 Log: Added handling to the authentication callback for passwords specified on the command line and the -N|--no-pass option. Cleaned up straggling debug output. -Kalim Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-18 06:19:32 UTC (rev 9379) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-18 06:50:58 UTC (rev 9380) @@ -140,18 +140,26 @@ strncpy(pUsername, username, maxLenUsername - 1); strncpy(authUsername, username, maxLenUsername - 1); -char *pass = getpass(Password: ); -if (pass) -fstrcpy(temp, pass); -if (temp[strlen(temp) - 1] == '\n') /* A new line? */ +if (cmdline_auth_info.got_pass) { -temp[strlen(temp) - 1] = '\0'; -} -if (temp[0] != '\0') +strncpy(pPassword, cmdline_auth_info.password, maxLenPassword - 1); +strncpy(authPassword, cmdline_auth_info.password, maxLenPassword - 1); +} +else { -strncpy(pPassword, temp, maxLenPassword - 1); -strncpy(authPassword, pPassword, maxLenPassword - 1); -} +char *pass = getpass(Password: ); +if (pass) +fstrcpy(temp, pass); +if (temp[strlen(temp) - 1] == '\n') /* A new line? */ +{ +temp[strlen(temp) - 1] = '\0'; +} +if (temp[0] != '\0') +{ +strncpy(pPassword, temp, maxLenPassword - 1); +strncpy(authPassword, pPassword, maxLenPassword - 1); +} +} authSet = 1; } } @@ -2376,7 +2384,7 @@ pstrcat(src, oname); pstrcat(dest, nname); -d_printf(O: %s\nN: %s\n, src, dest); +DEBUG(4, (O: %s\nN: %s\n, src, dest)); err = smbc_rename(src, dest); if (err 0)
svn commit: samba r9317 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-08-16 05:34:01 + (Tue, 16 Aug 2005) New Revision: 9317 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=9317 Log: Modified authentication callback to pick up command line args. Added rename command. -Kalim Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-16 05:06:33 UTC (rev 9316) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-16 05:34:01 UTC (rev 9317) @@ -132,34 +132,14 @@ } else { -d_printf(Workgroup: [%s] , pWorkgroup); -fgets(temp, sizeof(temp), stdin); +d_printf(Workgroup: %s\n, lp_workgroup()); +strncpy(pWorkgroup, lp_workgroup(), maxLenWorkgroup - 1); +strncpy(authWorkgroup, lp_workgroup(), maxLenWorkgroup - 1); -if (temp[strlen(temp) - 1] == '\n') /* A new line? */ -{ -temp[strlen(temp) - 1] = '\0'; -} +d_printf(Username: %s\n, username); +strncpy(pUsername, username, maxLenUsername - 1); +strncpy(authUsername, username, maxLenUsername - 1); -if (temp[0] != '\0') -{ -strncpy(pWorkgroup, temp, maxLenWorkgroup - 1); -strncpy(authWorkgroup, temp, maxLenWorkgroup - 1); -} - -d_printf(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); -strncpy(authUsername, pUsername, maxLenUsername - 1); -} - char *pass = getpass(Password: ); if (pass) fstrcpy(temp, pass); @@ -2378,27 +2358,34 @@ static int cmd_rename(void) { - pstring src,dest; - pstring buf,buf2; +int err; + pstring src, dest; + pstring oname, nname; - pstrcpy(src,cur_dir); - pstrcpy(dest,cur_dir); +pstrcpy(src, smb:); +pstrcat(src, service); + pstrcat(src, cur_dir); + pstrcpy(dest, src); - if (!next_token_nr(NULL,buf,NULL,sizeof(buf)) || - !next_token_nr(NULL,buf2,NULL, sizeof(buf2))) { + if (!next_token_nr(NULL,oname,NULL,sizeof(oname)) || + !next_token_nr(NULL,nname,NULL, sizeof(nname))) { d_printf(rename src dest\n); return 1; } - pstrcat(src,buf); - pstrcat(dest,buf2); + pstrcat(src, oname); + pstrcat(dest, nname); + +d_printf(O: %s\nN: %s\n, src, dest); - if (!cli_rename(cli, src, dest)) { - d_printf(%s renaming files\n,cli_errstr(cli)); - return 1; - } - - return 0; + err = smbc_rename(src, dest); +if (err 0) +{ +d_printf(%s renaming files\n, strerror(errno)); +return 1; +} + +return 0; } / @@ -2887,7 +2874,7 @@ {rd,cmd_rmdir,directory remove a directory,{COMPL_NONE,COMPL_NONE}}, {recurse,cmd_recurse,toggle directory recursion for mget and mput,{COMPL_NONE,COMPL_NONE}}, /* {reget,cmd_reget,remote name [local name] get a file restarting at end of local file,{COMPL_REMOTE,COMPL_LOCAL}},*/ -/* {rename,cmd_rename,src dest rename some files,{COMPL_REMOTE,COMPL_REMOTE}},*/ + {rename,cmd_rename,src dest rename some files,{COMPL_REMOTE,COMPL_REMOTE}}, /* {reput,cmd_reput,local name [remote name] put a file restarting at end of remote file,{COMPL_LOCAL,COMPL_REMOTE}},*/ /* {rm,cmd_del,mask delete all matching files,{COMPL_REMOTE,COMPL_NONE}},*/ {rmdir,cmd_rmdir,directory remove a directory,{COMPL_NONE,COMPL_NONE}},
svn commit: samba r9306 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-08-15 03:01:16 + (Mon, 15 Aug 2005) New Revision: 9306 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=9306 Log: Fixed minor errors with mkdir. Added rudimentary dir command to make testing easier while writing do_list related stuff. -Kalim Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-15 01:38:21 UTC (rev 9305) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-15 03:01:16 UTC (rev 9306) @@ -678,13 +678,40 @@ reset_do_list_queue(); } +/*** + Return a string representing an attribute for a file. +/ + +fstring *mode_t_string(mode_t mode) +{ + static fstring attrstr; + + attrstr[0] = 0; + +S_ISDIR(mode) ? fstrcat(attrstr, d) : fstrcat(attrstr, -); +(mode S_IRUSR) ? fstrcat(attrstr, r) : fstrcat(attrstr, -); +(mode S_IWUSR) ? fstrcat(attrstr, w) : fstrcat(attrstr, -); +(mode S_IXUSR) ? fstrcat(attrstr, x) : fstrcat(attrstr, -); + +(mode S_IRGRP) ? fstrcat(attrstr, r) : fstrcat(attrstr, -); +(mode S_IWGRP) ? fstrcat(attrstr, w) : fstrcat(attrstr, -); +(mode S_IXGRP) ? fstrcat(attrstr, x) : fstrcat(attrstr, -); + +(mode S_IROTH) ? fstrcat(attrstr, r) : fstrcat(attrstr, -); +(mode S_IWOTH) ? fstrcat(attrstr, w) : fstrcat(attrstr, -); +(mode S_IXOTH) ? fstrcat(attrstr, x) : fstrcat(attrstr, -); + + + return(attrstr); +} + / Get a directory listing. / static int cmd_dir(void) { - uint16 attribute = aDIR | aSYSTEM | aHIDDEN; + /*uint16 attribute = aDIR | aSYSTEM | aHIDDEN; pstring mask; pstring buf; char *p=buf; @@ -715,7 +742,66 @@ DEBUG(3, (Total bytes listed: %.0f\n, dir_total)); - return rc; + return rc;*/ + +int dh; +pstring res; +pstring dpath; +pstring dentname; +struct stat stat; +struct smbc_dirent* dent; + +pstrcpy(dpath, service); +pstrcat(dpath, cur_dir); +pstrcpy(res, smb:); +pstrcat(res, dpath); + +if ((dh = smbc_opendir(res)) 1) +{ +d_printf(Error: %s opening %s\n, strerror(errno), res); +return 1; +} + +while (dent = smbc_readdir(dh)) +{ +d_printf( %-30s, dent-name); + +switch(dent-smbc_type) +{ +case SMBC_WORKGROUP: +case SMBC_SERVER: +case SMBC_FILE_SHARE: +case SMBC_PRINTER_SHARE: +case SMBC_COMMS_SHARE: +case SMBC_IPC_SHARE: +break; +case SMBC_DIR: +case SMBC_FILE: +pstrcpy(dentname, res); +pstrcat(dentname, /); +pstrcat(dentname, dent-name); +if (smbc_stat(dentname, stat) 0) +{ +d_printf( error: %s, strerror(errno)); +} +else +{ +time_t t = stat.st_mtime; +pstring time_str; +pstrcpy(time_str, asctime(LocalTime(t))); +time_str[strlen(time_str)-1] = 0; +d_printf(%10.10s %8.0f %s, *mode_t_string(stat.st_mode), (double)stat.st_size, time_str); +} +break; + +case SMBC_LINK: +break; +} + +printf(\n); +} +smbc_closedir(dh); +return 0; } / @@ -1083,7 +1169,7 @@ { if (smbc_mkdir(name, 755) 0) { -DEBUG(2, (Error: %s making remote directory %s\n, strerror(errno), name)); +d_printf(Error: %s making remote directory %s\n, strerror(errno), name); return False; } @@ -1157,10 +1243,8 @@ pstrcat(targetname, ddir2); DEBUG(3, (Recursively making directory %s\n, targetname)); if ((dh = smbc_opendir(targetname)) 0) { -if (!do_mkdir(targetname)) { -d_printf(Error: %s making remote directory %s\n, strerror(errno), targetname); -break; -} +if (!do_mkdir(targetname)) +return 1; } else smbc_closedir(dh); @@ -1175,7 +1259,7 @@ pstrcat(targetname, mask); if (!do_mkdir(targetname)) -d_printf(Error: %s making remote directory %s\n, strerror(errno), targetname); +return 1; } return 0; @@ -2771,7 +2855,7 @@ /* {chmod,cmd_chmod,src mode chmod a file
svn commit: samba r9169 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-08-07 01:25:25 + (Sun, 07 Aug 2005) New Revision: 9169 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=9169 Log: Added mkdir (with support for recursion) and enabled the recurse command. -Kalim Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-06 23:41:18 UTC (rev 9168) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-07 01:25:25 UTC (rev 9169) @@ -1081,21 +1081,13 @@ static BOOL do_mkdir(char *name) { - struct cli_state *targetcli; - pstring targetname; - - if ( !cli_resolve_path( , cli, name, targetcli, targetname ) ) { - d_printf(mkdir %s: %s\n, name, cli_errstr(cli)); - return False; - } - - if (!cli_mkdir(targetcli, targetname)) { - d_printf(%s making remote directory %s\n, -cli_errstr(targetcli),name); - return(False); - } - - return(True); + if (smbc_mkdir(name, 755) 0) +{ +DEBUG(2, (Error: %s making remote directory %s\n, strerror(errno), name)); +return False; +} + + return True; } / @@ -1133,8 +1125,10 @@ static int cmd_mkdir(void) { +int dh; pstring mask; pstring buf; +pstring targetname; char *p=buf; pstrcpy(mask,cur_dir); @@ -1145,8 +1139,8 @@ return 1; } pstrcat(mask,p); - - if (recurse) { + +if (recurse) { pstring ddir; pstring ddir2; *ddir2 = 0; @@ -1156,15 +1150,33 @@ p = strtok(ddir,/\\); while (p) { pstrcat(ddir2,p); - if (!cli_chkpath(cli, ddir2)) { - do_mkdir(ddir2); - } + +pstrcpy(targetname, smb:); +pstrcat(targetname, service); +pstrcat(targetname, /); +pstrcat(targetname, ddir2); +DEBUG(3, (Recursively making directory %s\n, targetname)); +if ((dh = smbc_opendir(targetname)) 0) { +if (!do_mkdir(targetname)) { +d_printf(Error: %s making remote directory %s\n, strerror(errno), targetname); +break; +} +} +else +smbc_closedir(dh); + pstrcat(ddir2,/); p = strtok(NULL,/\\); - } - } else { - do_mkdir(mask); + } } +else { +pstrcpy(targetname, smb:); +pstrcat(targetname, service); +pstrcat(targetname, mask); + +if (!do_mkdir(targetname)) +d_printf(Error: %s making remote directory %s\n, strerror(errno), targetname); + } return 0; } @@ -2774,9 +2786,9 @@ {lowercase,cmd_lowercase,toggle lowercasing of filenames for get,{COMPL_NONE,COMPL_NONE}}, /* {ls,cmd_dir,mask list the contents of the current directory,{COMPL_REMOTE,COMPL_NONE}},*/ /* {mask,cmd_select,mask mask all filenames against this,{COMPL_REMOTE,COMPL_NONE}}, */ -/* {md,cmd_mkdir,directory make a directory,{COMPL_NONE,COMPL_NONE}}, */ + {md,cmd_mkdir,directory make a directory,{COMPL_NONE,COMPL_NONE}}, /* {mget,cmd_mget,mask get all the matching files,{COMPL_REMOTE,COMPL_NONE}}, */ -/* {mkdir,cmd_mkdir,directory make a directory,{COMPL_NONE,COMPL_NONE}}, */ + {mkdir,cmd_mkdir,directory make a directory,{COMPL_NONE,COMPL_NONE}}, /* {more,cmd_more,remote name view a remote file with your pager,{COMPL_REMOTE,COMPL_NONE}}, */ /* {mput,cmd_mput,mask put all matching files,{COMPL_REMOTE,COMPL_NONE}}, */ {newer,cmd_newer,file only mget files newer than the specified local file,{COMPL_LOCAL,COMPL_NONE}}, @@ -2789,7 +2801,7 @@ /* {queue,cmd_queue,show the print queue,{COMPL_NONE,COMPL_NONE}}, */ {quit,cmd_quit,logoff the server,{COMPL_NONE,COMPL_NONE}}, {rd,cmd_rmdir,directory remove a directory,{COMPL_NONE,COMPL_NONE}}, -/* {recurse,cmd_recurse,toggle directory recursion for mget and mput,{COMPL_NONE,COMPL_NONE}}, */ + {recurse,cmd_recurse,toggle directory recursion for mget and mput,{COMPL_NONE,COMPL_NONE}}, /* {reget,cmd_reget,remote name [local name] get a file restarting at end of local file,{COMPL_REMOTE,COMPL_LOCAL}},*/ /* {rename,cmd_rename,src dest rename some files,{COMPL_REMOTE,COMPL_REMOTE}},*/ /* {reput,cmd_reput,local name [remote name] put a file restarting at end of remote file,{COMPL_LOCAL,COMPL_REMOTE}},*/
svn commit: samba r8866 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-07-31 20:20:27 + (Sun, 31 Jul 2005) New Revision: 8866 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=8866 Log: Moved authentication function into client.c and got rid of the header file. Still needs a lot of work, but it's more usable. Commented out the non-working type stuff from the command table to avoid nasty segfaults. Modified 'cd' command to parse relative paths a little better. Removed: branches/SOC/SAMBA_3_0/source/client/get_auth_data_fn.h Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Sorry, the patch is too large (564 lines) to include; please use WebSVN to see it! WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=8866
svn commit: samba r8861 - in branches/SOC/SAMBA_3_0/source: .
Author: kalim Date: 2005-07-30 23:02:37 + (Sat, 30 Jul 2005) New Revision: 8861 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=8861 Log: Modified bin/smbclient rule to use shared library when building. -Kalim Modified: branches/SOC/SAMBA_3_0/source/Makefile.in Changeset: Modified: branches/SOC/SAMBA_3_0/source/Makefile.in === --- branches/SOC/SAMBA_3_0/source/Makefile.in 2005-07-30 05:08:13 UTC (rev 8860) +++ branches/SOC/SAMBA_3_0/source/Makefile.in 2005-07-30 23:02:37 UTC (rev 8861) @@ -857,9 +857,9 @@ $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ $(KRB5LIBS) $(LDAP_LIBS) -bin/[EMAIL PROTECTED]@: $(CLIENT_OBJ) @BUILD_POPT@ bin/.dummy +bin/[EMAIL PROTECTED]@: $(CLIENT_OBJ) @BUILD_POPT@ bin/libsmbclient.a bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) + @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) -Lbin -lsmbclient bin/[EMAIL PROTECTED]@: $(NET_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@
svn commit: samba r8767 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-07-26 01:57:14 + (Tue, 26 Jul 2005) New Revision: 8767 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=8767 Log: Changed #include directives back to quoted form - caught by abartlett. Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-07-26 01:56:00 UTC (rev 8766) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-07-26 01:57:14 UTC (rev 8767) @@ -24,8 +24,8 @@ #define NO_SYSLOG -#include includes.h -#include libsmbclient.h +#include includes.h +#include libsmbclient.h #include client/client_proto.h #include client/get_auth_data_fn.h #ifndef REGISTER
svn commit: samba r8768 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-07-26 02:01:15 + (Tue, 26 Jul 2005) New Revision: 8768 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=8768 Log: Authentication function for libsmbclient. Needs some work, but is ok for testing puposes. -Kalim Added: branches/SOC/SAMBA_3_0/source/client/get_auth_data_fn.h Changeset: Added: branches/SOC/SAMBA_3_0/source/client/get_auth_data_fn.h === --- branches/SOC/SAMBA_3_0/source/client/get_auth_data_fn.h 2005-07-26 01:57:14 UTC (rev 8767) +++ branches/SOC/SAMBA_3_0/source/client/get_auth_data_fn.h 2005-07-26 02:01:15 UTC (rev 8768) @@ -0,0 +1,52 @@ +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); +} +}
svn commit: samba r8751 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-07-25 05:30:40 + (Mon, 25 Jul 2005) New Revision: 8751 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=8751 Log: Added initialization stuff for libsmb 'cd' command updated -kalim Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-07-25 04:39:20 UTC (rev 8750) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-07-25 05:30:40 UTC (rev 8751) @@ -5,6 +5,7 @@ Copyright (C) Simo Sorce 2001-2002 Copyright (C) Jelmer Vernooij 2003 Copyright (C) Gerald (Jerry) Carter2004 + Copyright (C) Kalim Moghul 2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,8 +24,10 @@ #define NO_SYSLOG -#include includes.h +#include includes.h +#include libsmbclient.h #include client/client_proto.h +#include client/get_auth_data_fn.h #ifndef REGISTER #define REGISTER 0 #endif @@ -35,7 +38,7 @@ extern BOOL in_client; static int port = 0; pstring cur_dir = \\; -static pstring cd_path = ; +//static pstring cd_path = ; static pstring service; static pstring desthost; static pstring username; @@ -258,33 +261,60 @@ struct cli_state *targetcli; SMB_STRUCT_STAT sbuf; uint32 attributes; +int dh; int ret = 1; - - dos_format(newdir); + + unix_format(newdir); /* Save the current directory in case the new directory is invalid */ pstrcpy(saved_dir, cur_dir); - if (*p == '\\') + if (*p == '/') pstrcpy(cur_dir,p); else pstrcat(cur_dir,p); - if (*(cur_dir+strlen(cur_dir)-1) != '\\') { - pstrcat(cur_dir, \\); + if (*(cur_dir+strlen(cur_dir)-1) != '/') { + pstrcat(cur_dir, /); } - dos_clean_name(cur_dir); +/*dos_clean_name(cur_dir); pstrcpy( dname, cur_dir ); pstrcat(cur_dir,\\); - dos_clean_name(cur_dir); - - if ( !cli_resolve_path( , cli, dname, targetcli, targetpath ) ) { + dos_clean_name(cur_dir);*/ + + +/* TODO: cleanup debugging print statements*/ +/*d_printf(service: %s\n, service); +d_printf(desthost: %s\n, desthost); +d_printf(username: %s\n, username); +d_printf(calling_name: %s\n, calling_name); +d_printf(cur_dir: %s\n, cur_dir);*/ + +/* Format the directory in a libmsmbclient friendly way */ +unix_clean_name(cur_dir); + pstrcpy( dname, cur_dir ); +pstrcpy(targetpath, smb:); +pstrcat(targetpath, service); + pstrcat(targetpath, dname); +unix_format(targetpath); +/*d_printf(Saved: %s\n, cur_dir); +d_printf(Result: %s\n, targetpath);*/ + + /*if ( !cli_resolve_path( , cli, dname, targetcli, targetpath ) ) { d_printf(cd %s: %s\n, dname, cli_errstr(cli)); pstrcpy(cur_dir,saved_dir); goto out; - } + }*/ +dh = smbc_opendir(targetpath); +if (dh 0) +{ +d_printf(%s changing to directory %s\n, strerror(errno), cur_dir); +pstrcpy(cur_dir, saved_dir); +return 1; +} +smbc_closedir(dh); if ( strequal(targetpath,\\ ) ) @@ -292,7 +322,7 @@ /* use a trans2_qpathinfo to test directories for modern servers */ - if ( targetcli-protocol = PROTOCOL_LANMAN2 ) { + /*if ( targetcli-protocol = PROTOCOL_LANMAN2 ) { if ( !cli_qpathinfo_basic( targetcli, targetpath, sbuf, attributes ) ) { d_printf(cd %s: %s\n, dname, cli_errstr(targetcli)); pstrcpy(cur_dir,saved_dir); @@ -313,13 +343,11 @@ pstrcpy(cur_dir,saved_dir); goto out; } - } + }*/ ret = 0; out: - - pstrcpy(cd_path,cur_dir); return ret; } @@ -2427,7 +2455,6 @@ if (next_token_nr(NULL,buf,NULL,sizeof(buf))) chdir(buf); -d_printf(Local directory now %s\n, sys_getwd(d)); DEBUG(2,(the local directory is now %s\n,sys_getwd(d))); return 0; @@ -2714,6 +2741,8 @@ {history,cmd_history,displays the command history,{COMPL_NONE,COMPL_NONE}}, {lcd,cmd_lcd,[directory] change/report the local current working directory,{COMPL_LOCAL,COMPL_NONE}}, {link,cmd_link,oldname newname create a UNIX hard link,{COMPL_REMOTE,COMPL_REMOTE}}, + {listconnect,cmd_list_connect,list open connections,{COMPL_NONE,COMPL_NONE}}, + {logon,cmd_logon,establish new logon,{COMPL_NONE,COMPL_NONE}}, {lowercase,cmd_lowercase,toggle lowercasing of filenames for get,{COMPL_NONE
svn commit: samba r8534 - in branches/SOC/SAMBA_3_0/source/client: .
Author: kalim Date: 2005-07-18 02:05:28 + (Mon, 18 Jul 2005) New Revision: 8534 WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=8534 Log: Removed unused printmode command. Modified: branches/SOC/SAMBA_3_0/source/client/client.c Changeset: Modified: branches/SOC/SAMBA_3_0/source/client/client.c === --- branches/SOC/SAMBA_3_0/source/client/client.c 2005-07-18 00:08:46 UTC (rev 8533) +++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-07-18 02:05:28 UTC (rev 8534) @@ -73,8 +73,6 @@ static BOOL prompt = True; -static int printmode = 1; - static BOOL recurse = False; BOOL lowercase = False; @@ -2419,43 +2417,6 @@ } / - Do a printmode command. -/ - -static int cmd_printmode(void) -{ - fstring buf; - fstring mode; - - if (next_token_nr(NULL,buf,NULL,sizeof(buf))) { - if (strequal(buf,text)) { - printmode = 0; - } else { - if (strequal(buf,graphics)) - printmode = 1; - else - printmode = atoi(buf); - } - } - - switch(printmode) { - case 0: - fstrcpy(mode,text); - break; - case 1: - fstrcpy(mode,graphics); - break; - default: - slprintf(mode,sizeof(mode)-1,%d,printmode); - break; - } - - DEBUG(2,(the printmode is now %s\n,mode)); - - return 0; -} - -/ Do the lcd command. / @@ -2466,6 +2427,7 @@ if (next_token_nr(NULL,buf,NULL,sizeof(buf))) chdir(buf); +d_printf(Local directory now %s\n, sys_getwd(d)); DEBUG(2,(the local directory is now %s\n,sys_getwd(d))); return 0; @@ -2763,7 +2725,6 @@ {newer,cmd_newer,file only mget files newer than the specified local file,{COMPL_LOCAL,COMPL_NONE}}, {open,cmd_open,mask open a file,{COMPL_REMOTE,COMPL_NONE}}, {print,cmd_print,file name print a file,{COMPL_NONE,COMPL_NONE}}, - {printmode,cmd_printmode,graphics or text set the print mode,{COMPL_NONE,COMPL_NONE}}, {prompt,cmd_prompt,toggle prompting for filenames for mget and mput,{COMPL_NONE,COMPL_NONE}}, {put,cmd_put,local name [remote name] put a file,{COMPL_LOCAL,COMPL_REMOTE}}, {pwd,cmd_pwd,show current remote directory (same as 'cd' with no args),{COMPL_NONE,COMPL_NONE}},