svn commit: samba r19529 - in branches: SAMBA_3_0/source SAMBA_3_0/source/client SAMBA_3_0_23/source SAMBA_3_0_23/source/client SAMBA_3_0_24/source SAMBA_3_0_24/source/client

jra at samba.org jra at samba.org
Wed Nov 1 17:18:09 GMT 2006


Author: jra
Date: 2006-11-01 17:18:08 +0000 (Wed, 01 Nov 2006)
New Revision: 19529

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19529

Log:
Added showacls togle. Previously was vendor-specific code.
Merging these in - should have been merged back before (will
be tidied up later).
Jeremy.

Modified:
   branches/SAMBA_3_0/source/Makefile.in
   branches/SAMBA_3_0/source/client/client.c
   branches/SAMBA_3_0_23/source/Makefile.in
   branches/SAMBA_3_0_23/source/client/client.c
   branches/SAMBA_3_0_24/source/Makefile.in
   branches/SAMBA_3_0_24/source/client/client.c


Changeset:
Modified: branches/SAMBA_3_0/source/Makefile.in
===================================================================
--- branches/SAMBA_3_0/source/Makefile.in	2006-11-01 11:19:33 UTC (rev 19528)
+++ branches/SAMBA_3_0/source/Makefile.in	2006-11-01 17:18:08 UTC (rev 19529)
@@ -597,11 +597,13 @@
 
 CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \
 	     $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) $(LIBMSRPC_GEN_OBJ) \
-             $(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ)
+             $(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
+	     lib/display_sec.o
 
 TOOL_OBJ = client/smbctool.o client/clitar.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
 	     $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
-             $(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ)
+             $(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
+	     lib/display_sec.o
 
 NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_domain.o utils/net_help.o \
 	   utils/net_rap.o utils/net_rpc.o utils/net_rpc_samsync.o \

Modified: branches/SAMBA_3_0/source/client/client.c
===================================================================
--- branches/SAMBA_3_0/source/client/client.c	2006-11-01 11:19:33 UTC (rev 19528)
+++ branches/SAMBA_3_0/source/client/client.c	2006-11-01 17:18:08 UTC (rev 19529)
@@ -50,6 +50,10 @@
 static int process_tok(pstring tok);
 static int cmd_help(void);
 
+static TALLOC_CTX *ctx;
+#define CREATE_ACCESS_READ READ_CONTROL_ACCESS
+static pstring cwd;
+
 /* 30 second timeout on most commands */
 #define CLIENT_TIMEOUT (30*1000)
 #define SHORT_TIMEOUT (5*1000)
@@ -73,6 +77,7 @@
 static BOOL prompt = True;
 
 static BOOL recurse = False;
+static BOOL showacls = False;
 BOOL lowercase = False;
 
 static struct in_addr dest_ip;
@@ -377,12 +382,46 @@
 {
 	if (do_this_one(finfo)) {
 		time_t t = finfo->mtime_ts.tv_sec; /* the time is assumed to be passed as GMT */
-		d_printf("  %-30s%7.7s %8.0f  %s",
-			 finfo->name,
-			 attrib_string(finfo->mode),
-			 (double)finfo->size,
-			 time_to_asc(&t));
-		dir_total += finfo->size;
+		if (!showacls) {
+			d_printf("  %-30s%7.7s %8.0f  %s",
+				 finfo->name,
+				 attrib_string(finfo->mode),
+			 	(double)finfo->size,
+				time_to_asc(&t));
+			dir_total += finfo->size;
+		} else {
+			pstring afname;
+			int fnum;
+
+			/* skip if this is . or .. */
+			if ( strequal(finfo->name,"..") || strequal(finfo->name,".") )
+				return;
+			/* create absolute filename for cli_nt_create() FIXME */
+			pstrcpy( afname, cwd);
+			pstrcat( afname, "\\");
+			pstrcat( afname, finfo->name);
+			/* print file meta date header */
+			d_printf( "FILENAME:%s\n", afname);
+			d_printf( "MODE:%s\n", attrib_string(finfo->mode));
+			d_printf( "SIZE:%.0f\n", (double)finfo->size);
+			d_printf( "MTIME:%s", time_to_asc(&t));
+			fnum = cli_nt_create(cli, afname, CREATE_ACCESS_READ);
+			if (fnum == -1) {
+				DEBUG( 0, ("display_finfo() Failed to open %s: %s\n",
+					afname,
+					cli_errstr( cli)));
+			} else {
+				SEC_DESC *sd = NULL;
+				sd = cli_query_secdesc(cli, fnum, ctx);
+				if (!sd) {
+					DEBUG( 0, ("display_finfo() failed to "
+						"get security descriptor: %s",
+						cli_errstr( cli)));
+				} else {
+					display_sec_desc(sd);
+				}
+			}
+		}
 	}
 }
 
@@ -618,8 +657,11 @@
 					save_ch = next_file +
 						strlen(next_file) - 2;
 					*save_ch = '\0';
+					if (showacls) /* cwd is only used if showacls is on */
+						pstrcpy( cwd, next_file);
 				}
-				d_printf("\n%s\n",next_file);
+				if (!showacls) /* don't disturbe the showacls output */
+					d_printf("\n%s\n",next_file);
 				if (save_ch) {
 					*save_ch = CLI_DIRSEP_CHAR;
 				}
@@ -1085,6 +1127,7 @@
 static int cmd_quit(void)
 {
 	cli_cm_shutdown();
+	talloc_destroy( ctx);
 	exit(0);
 	/* NOTREACHED */
 	return 0;
@@ -2584,6 +2627,25 @@
 }
 
 /****************************************************************************
+ Toggle the showacls flag.
+****************************************************************************/
+
+static int cmd_showacls(void)
+{
+	showacls = !showacls;
+	DEBUG(2,("showacls is now %s\n",showacls?"on":"off"));
+
+	if (!ctx && showacls)
+		ctx = talloc_init("smbclient:showacls");
+		if (!ctx) {
+			DEBUG( 0, ("cmd_showacls() out of memory.  talloc_init() failed.\n"));
+	}
+
+	return 0;
+}
+
+
+/****************************************************************************
  Toggle the recurse flag.
 ****************************************************************************/
 
@@ -2986,6 +3048,7 @@
   {"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}},
+  {"showacls",cmd_showacls,"toggle if ACLs are shown or not",{COMPL_NONE,COMPL_NONE}},  
   {"setmode",cmd_setmode,"filename <setmode string> change modes of file",{COMPL_REMOTE,COMPL_NONE}},
   {"stat",cmd_stat,"filename Do a UNIX extensions stat call on a file",{COMPL_REMOTE,COMPL_REMOTE}},
   {"symlink",cmd_symlink,"<oldname> <newname> create a UNIX symlink",{COMPL_REMOTE,COMPL_REMOTE}},
@@ -3822,5 +3885,6 @@
 		return 1;
 	}
 
+	talloc_destroy( ctx);
 	return rc;
 }

Modified: branches/SAMBA_3_0_23/source/Makefile.in
===================================================================
--- branches/SAMBA_3_0_23/source/Makefile.in	2006-11-01 11:19:33 UTC (rev 19528)
+++ branches/SAMBA_3_0_23/source/Makefile.in	2006-11-01 17:18:08 UTC (rev 19529)
@@ -562,7 +562,8 @@
 
 CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \
 	     $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
-             $(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ)
+             $(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
+	     lib/display_sec.o
 
 TOOL_OBJ = client/smbctool.o client/clitar.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
 	     $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \

Modified: branches/SAMBA_3_0_23/source/client/client.c
===================================================================
--- branches/SAMBA_3_0_23/source/client/client.c	2006-11-01 11:19:33 UTC (rev 19528)
+++ branches/SAMBA_3_0_23/source/client/client.c	2006-11-01 17:18:08 UTC (rev 19529)
@@ -49,6 +49,10 @@
 static int process_tok(pstring tok);
 static int cmd_help(void);
 
+static TALLOC_CTX *ctx;
+#define CREATE_ACCESS_READ READ_CONTROL_ACCESS
+static pstring cwd;
+
 /* 30 second timeout on most commands */
 #define CLIENT_TIMEOUT (30*1000)
 #define SHORT_TIMEOUT (5*1000)
@@ -72,6 +76,7 @@
 static BOOL prompt = True;
 
 static BOOL recurse = False;
+static BOOL showacls = False;
 BOOL lowercase = False;
 
 static struct in_addr dest_ip;
@@ -375,12 +380,46 @@
 {
 	if (do_this_one(finfo)) {
 		time_t t = finfo->mtime; /* the time is assumed to be passed as GMT */
-		d_printf("  %-30s%7.7s %8.0f  %s",
-			 finfo->name,
-			 attrib_string(finfo->mode),
-			 (double)finfo->size,
-			 time_to_asc(&t));
-		dir_total += finfo->size;
+		if (!showacls) {
+			d_printf("  %-30s%7.7s %8.0f  %s",
+				 finfo->name,
+				 attrib_string(finfo->mode),
+				 (double)finfo->size,
+				 time_to_asc(&t));
+			dir_total += finfo->size;
+		} else { /* showacls */
+			static pstring afname;
+			int fnum;
+
+			/* skip if this is . or .. */
+			if ( strequal(finfo->name,"..") || strequal(finfo->name,".") )
+				return;
+			/* create absolute filename for cli_nt_create() FIXME */
+			pstrcpy( afname, cwd);
+			pstrcat( afname, "\\");
+			pstrcat( afname, finfo->name);
+			/* print file meta date header */
+			d_printf( "FILENAME:%s\n", afname);
+			d_printf( "MODE:%s\n", attrib_string(finfo->mode));
+			d_printf( "SIZE:%.0f\n", (double)finfo->size);
+			d_printf( "MTIME:%s", time_to_asc(&t));
+			fnum = cli_nt_create(cli, afname, CREATE_ACCESS_READ);
+			if (fnum == -1) {
+				DEBUG( 0, ("display_finfo() Failed to open %s: %s\n",
+							afname,
+							cli_errstr( cli)));
+			} else {
+				SEC_DESC *sd = NULL;
+				sd = cli_query_secdesc(cli, fnum, ctx);
+				if (!sd) {
+					DEBUG( 0, ("display_finfo() failed to "
+						"get security descriptor: %s",
+						cli_errstr( cli)));
+				} else {
+					display_sec_desc(sd);
+				}
+			}
+		}
 	}
 }
 
@@ -616,8 +655,11 @@
 					save_ch = next_file +
 						strlen(next_file) - 2;
 					*save_ch = '\0';
+					if (showacls) /* cwd is only used if showacls is on */
+						pstrcpy( cwd, next_file);
 				}
-				d_printf("\n%s\n",next_file);
+				if (!showacls) /* don't disturbe the showacls output */
+					d_printf("\n%s\n",next_file);
 				if (save_ch) {
 					*save_ch = '\\';
 				}
@@ -1083,6 +1125,7 @@
 static int cmd_quit(void)
 {
 	cli_cm_shutdown();
+	talloc_destroy( ctx);
 	exit(0);
 	/* NOTREACHED */
 	return 0;
@@ -2419,6 +2462,25 @@
 }
 
 /****************************************************************************
+ Toggle the showacls flag.
+****************************************************************************/
+
+static int cmd_showacls(void)
+{
+	showacls = !showacls;
+	DEBUG(2,("showacls is now %s\n",showacls?"on":"off"));
+
+	if (!ctx && showacls)
+		ctx = talloc_init("smbclient:showacls");
+		if (!ctx) {
+			DEBUG( 0, ("cmd_showacls() out of memory.  talloc_init() failed.\n"));
+	}
+
+	return 0;
+}
+
+
+/****************************************************************************
  Toggle the recurse flag.
 ****************************************************************************/
 
@@ -2819,6 +2881,7 @@
   {"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}},
+  {"showacls",cmd_showacls,"toggle if ACLs are shown or not",{COMPL_NONE,COMPL_NONE}},  
   {"setmode",cmd_setmode,"filename <setmode string> change modes of file",{COMPL_REMOTE,COMPL_NONE}},
   {"stat",cmd_stat,"filename Do a UNIX extensions stat call on a file",{COMPL_REMOTE,COMPL_REMOTE}},
   {"symlink",cmd_symlink,"<oldname> <newname> create a UNIX symlink",{COMPL_REMOTE,COMPL_REMOTE}},
@@ -3623,5 +3686,6 @@
 		return 1;
 	}
 
+	talloc_destroy( ctx);
 	return rc;
 }

Modified: branches/SAMBA_3_0_24/source/Makefile.in
===================================================================
--- branches/SAMBA_3_0_24/source/Makefile.in	2006-11-01 11:19:33 UTC (rev 19528)
+++ branches/SAMBA_3_0_24/source/Makefile.in	2006-11-01 17:18:08 UTC (rev 19529)
@@ -562,7 +562,8 @@
 
 CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \
 	     $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
-             $(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ)
+             $(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
+	     lib/display_sec.o
 
 TOOL_OBJ = client/smbctool.o client/clitar.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
 	     $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \

Modified: branches/SAMBA_3_0_24/source/client/client.c
===================================================================
--- branches/SAMBA_3_0_24/source/client/client.c	2006-11-01 11:19:33 UTC (rev 19528)
+++ branches/SAMBA_3_0_24/source/client/client.c	2006-11-01 17:18:08 UTC (rev 19529)
@@ -49,6 +49,10 @@
 static int process_tok(pstring tok);
 static int cmd_help(void);
 
+static TALLOC_CTX *ctx;
+#define CREATE_ACCESS_READ READ_CONTROL_ACCESS
+static pstring cwd;
+
 /* 30 second timeout on most commands */
 #define CLIENT_TIMEOUT (30*1000)
 #define SHORT_TIMEOUT (5*1000)
@@ -72,6 +76,7 @@
 static BOOL prompt = True;
 
 static BOOL recurse = False;
+static BOOL showacls = False;
 BOOL lowercase = False;
 
 static struct in_addr dest_ip;
@@ -375,12 +380,46 @@
 {
 	if (do_this_one(finfo)) {
 		time_t t = finfo->mtime; /* the time is assumed to be passed as GMT */
-		d_printf("  %-30s%7.7s %8.0f  %s",
-			 finfo->name,
-			 attrib_string(finfo->mode),
-			 (double)finfo->size,
-			 time_to_asc(&t));
-		dir_total += finfo->size;
+		if (!showacls) {
+			d_printf("  %-30s%7.7s %8.0f  %s",
+				 finfo->name,
+				 attrib_string(finfo->mode),
+				 (double)finfo->size,
+				 time_to_asc(&t));
+			dir_total += finfo->size;
+		} else { /* showacls */
+			static pstring afname;
+			int fnum;
+
+			/* skip if this is . or .. */
+			if ( strequal(finfo->name,"..") || strequal(finfo->name,".") )
+				return;
+			/* create absolute filename for cli_nt_create() FIXME */
+			pstrcpy( afname, cwd);
+			pstrcat( afname, "\\");
+			pstrcat( afname, finfo->name);
+			/* print file meta date header */
+			d_printf( "FILENAME:%s\n", afname);
+			d_printf( "MODE:%s\n", attrib_string(finfo->mode));
+			d_printf( "SIZE:%.0f\n", (double)finfo->size);
+			d_printf( "MTIME:%s", time_to_asc(&t));
+			fnum = cli_nt_create(cli, afname, CREATE_ACCESS_READ);
+			if (fnum == -1) {
+				DEBUG( 0, ("display_finfo() Failed to open %s: %s\n",
+							afname,
+							cli_errstr( cli)));
+			} else {
+				SEC_DESC *sd = NULL;
+				sd = cli_query_secdesc(cli, fnum, ctx);
+				if (!sd) {
+					DEBUG( 0, ("display_finfo() failed to "
+						"get security descriptor: %s",
+						cli_errstr( cli)));
+				} else {
+					display_sec_desc(sd);
+				}
+			}
+		}
 	}
 }
 
@@ -616,8 +655,11 @@
 					save_ch = next_file +
 						strlen(next_file) - 2;
 					*save_ch = '\0';
+					if (showacls) /* cwd is only used if showacls is on */
+						pstrcpy( cwd, next_file);
 				}
-				d_printf("\n%s\n",next_file);
+				if (!showacls) /* don't disturbe the showacls output */
+					d_printf("\n%s\n",next_file);
 				if (save_ch) {
 					*save_ch = '\\';
 				}
@@ -1083,6 +1125,7 @@
 static int cmd_quit(void)
 {
 	cli_cm_shutdown();
+	talloc_destroy( ctx);
 	exit(0);
 	/* NOTREACHED */
 	return 0;
@@ -2419,6 +2462,25 @@
 }
 
 /****************************************************************************
+ Toggle the showacls flag.
+****************************************************************************/
+
+static int cmd_showacls(void)
+{
+	showacls = !showacls;
+	DEBUG(2,("showacls is now %s\n",showacls?"on":"off"));
+
+	if (!ctx && showacls)
+		ctx = talloc_init("smbclient:showacls");
+		if (!ctx) {
+			DEBUG( 0, ("cmd_showacls() out of memory.  talloc_init() failed.\n"));
+	}
+
+	return 0;
+}
+
+
+/****************************************************************************
  Toggle the recurse flag.
 ****************************************************************************/
 
@@ -2819,6 +2881,7 @@
   {"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}},
+  {"showacls",cmd_showacls,"toggle if ACLs are shown or not",{COMPL_NONE,COMPL_NONE}},  
   {"setmode",cmd_setmode,"filename <setmode string> change modes of file",{COMPL_REMOTE,COMPL_NONE}},
   {"stat",cmd_stat,"filename Do a UNIX extensions stat call on a file",{COMPL_REMOTE,COMPL_REMOTE}},
   {"symlink",cmd_symlink,"<oldname> <newname> create a UNIX symlink",{COMPL_REMOTE,COMPL_REMOTE}},
@@ -3623,5 +3686,6 @@
 		return 1;
 	}
 
+	talloc_destroy( ctx);
 	return rc;
 }



More information about the samba-cvs mailing list