summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2001-03-15 02:15:05 +0000
committerGerald Carter <jerry@samba.org>2001-03-15 02:15:05 +0000
commit79dc43767eb59f0482ac1d8a62d71959e5611ecb (patch)
tree5d78e059ce09ed314352f612bb85f088a6b81b0b /source3
parent3257008e0d521fa53caacfc8d7885626868ab691 (diff)
downloadsamba-79dc43767eb59f0482ac1d8a62d71959e5611ecb.tar.gz
samba-79dc43767eb59f0482ac1d8a62d71959e5611ecb.tar.bz2
samba-79dc43767eb59f0482ac1d8a62d71959e5611ecb.zip
more updates. several spoolss commands added as placeholders
to be filled in one at a time. (This used to be commit 6aaac3766324302b995b5a55876bf2ab74af1ff8)
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/cli_spoolss.c2
-rw-r--r--source3/rpcclient/cmd_lsarpc.c1
-rw-r--r--source3/rpcclient/cmd_samr.c1
-rw-r--r--source3/rpcclient/cmd_spoolss.c86
-rw-r--r--source3/rpcclient/rpcclient.c29
5 files changed, 103 insertions, 16 deletions
diff --git a/source3/libsmb/cli_spoolss.c b/source3/libsmb/cli_spoolss.c
index af12f102d7..26ab99419a 100644
--- a/source3/libsmb/cli_spoolss.c
+++ b/source3/libsmb/cli_spoolss.c
@@ -136,7 +136,7 @@ uint32 cli_spoolss_open_printer_ex(struct cli_state *cli, char *printername,
/* Close a printer handle */
-uint32 cli_spoolss_closeprinter(struct cli_state *cli, POLICY_HND *pol)
+uint32 cli_spoolss_close_printer(struct cli_state *cli, POLICY_HND *pol)
{
prs_struct qbuf, rbuf;
SPOOL_Q_CLOSEPRINTER q;
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 3ae0b1e11d..77b61c8a2f 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -297,6 +297,7 @@ static uint32 cmd_lsa_enum_trust_dom(struct cli_state *cli, int argc, char **arg
/* List of commands exported by this module */
struct cmd_set lsarpc_commands[] = {
+ { "LSARPC", NULL, "" },
{ "lsaquery", cmd_lsa_query_info_policy, "Query info policy" },
{ "lookupsids", cmd_lsa_lookup_sids, "Convert SIDs to names" },
{ "lookupnames",cmd_lsa_lookup_names, "Convert names to SIDs" },
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index c7bed1368e..3772714cda 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -432,6 +432,7 @@ static uint32 cmd_samr_query_groupmem(struct cli_state *cli, int argc, char **ar
/* List of commands exported by this module */
struct cmd_set samr_commands[] = {
+ { "SAMR", NULL, "" },
{ "queryuser", cmd_samr_query_user, "Query user info" },
{ "querygroup", cmd_samr_query_group, "Query group info" },
{ "queryusergroups", cmd_samr_query_usergroups, "Query user groups" },
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index c7989d6882..8db769a8bd 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -31,6 +31,16 @@ extern pstring global_myname;
extern pstring username, password;
extern pstring workgroup;
+/**********************************************************************
+ * dummy function -- placeholder
+ */
+static uint32 cmd_spoolss_not_implemented (struct cli_state *cli,
+ int argc, char **argv)
+{
+ printf ("(*) This command is not currently implemented.\n");
+ return NT_STATUS_NO_PROBLEMO;
+}
+
/****************************************************************************
display sec_ace structure
****************************************************************************/
@@ -83,6 +93,55 @@ static void display_sec_desc(SEC_DESC *sec)
if (sec->off_dacl) display_sec_acl(sec->dacl);
}
+/***********************************************************************
+ * Get printer information
+ */
+static uint32 cmd_spoolss_open_printer_ex(struct cli_state *cli, int argc, char **argv)
+{
+ uint32 result = NT_STATUS_UNSUCCESSFUL;
+ pstring printername;
+ fstring server, user;
+ POLICY_HND hnd;
+
+ if (argc != 2) {
+ printf("Usage: openprinter <printername>\n");
+ return NT_STATUS_NOPROBLEMO;
+ }
+
+ if (!cli)
+ return NT_STATUS_UNSUCCESSFUL;
+
+
+ slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost);
+ strupper (server);
+ fstrcpy (user, cli->user_name);
+ fstrcpy (printername, argv[1]);
+
+
+ /* Initialise RPC connection */
+ if (!cli_nt_session_open (cli, PIPE_SPOOLSS)) {
+ fprintf (stderr, "Could not initialize spoolss pipe!\n");
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ /* Enumerate printers */
+ result = cli_spoolss_open_printer_ex (cli, printername, "",
+ PRINTER_ACCESS_USE, server, user, &hnd);
+
+ if (result == NT_STATUS_NOPROBLEMO) {
+ printf ("Printer %s opened successfully\n", printername);
+ result = cli_spoolss_close_printer (cli, &hnd);
+ if (result != NT_STATUS_NOPROBLEMO) {
+ printf ("Error closing printer handle! (%s)\n", get_nt_error_msg(result));
+ }
+ }
+
+ cli_nt_session_close(cli);
+
+ return result;
+}
+
+
/****************************************************************************
printer info level 0 display function
****************************************************************************/
@@ -245,7 +304,8 @@ static uint32 cmd_spoolss_enum_printers(struct cli_state *cli, int argc, char **
return NT_STATUS_UNSUCCESSFUL;
}
- /* Enumerate printers */
+ /* Enumerate printers -- Should we enumerate types other
+ than PRINTER_ENUM_LOCAL? Maybe accept as a parameter? --jerry */
ZERO_STRUCT(ctr);
result = cli_spoolss_enum_printers(cli, PRINTER_ENUM_LOCAL,
info_level, &returned, &ctr);
@@ -355,8 +415,9 @@ static uint32 cmd_spoolss_enum_ports(struct cli_state *cli, int argc, char **arg
return result;
}
-/* Get printer information */
-
+/***********************************************************************
+ * Get printer information
+ */
static uint32 cmd_spoolss_getprinter(struct cli_state *cli, int argc, char **argv)
{
POLICY_HND pol;
@@ -382,8 +443,7 @@ static uint32 cmd_spoolss_getprinter(struct cli_state *cli, int argc, char **arg
info_level = atoi(argv[2]);
}
- slprintf(printer_name, sizeof(fstring), "\\\\%s\\%s",
- server, argv[1]);
+ slprintf(printer_name, sizeof(fstring), "\\\\%s\\%s", server, argv[1]);
slprintf(station_name, sizeof(fstring), "\\\\%s", global_myname);
@@ -422,7 +482,8 @@ static uint32 cmd_spoolss_getprinter(struct cli_state *cli, int argc, char **arg
}
done:
- if (opened_hnd) cli_spoolss_closeprinter(cli, &pol);
+ if (opened_hnd)
+ cli_spoolss_close_printer(cli, &pol);
cli_nt_session_close(cli);
@@ -430,12 +491,19 @@ static uint32 cmd_spoolss_getprinter(struct cli_state *cli, int argc, char **arg
}
/* List of commands exported by this module */
-
struct cmd_set spoolss_commands[] = {
- { "enumprinters", cmd_spoolss_enum_printers, "Enumerate printers" },
+ { "SPOOLSS", NULL, "" },
+ { "adddriver", cmd_spoolss_not_implemented, "Add a print driver (*)" },
+ { "addprinter", cmd_spoolss_not_implemented, "Add a printer (*)" },
+ { "enumdata", cmd_spoolss_not_implemented, "Enumerate printer data (*)" },
+ { "enumjobs", cmd_spoolss_not_implemented, "Enumerate print jobs (*)" },
{ "enumports", cmd_spoolss_enum_ports, "Enumerate printer ports" },
+ { "enumprinters", cmd_spoolss_enum_printers, "Enumerate printers" },
+ { "getdata", cmd_spoolss_not_implemented, "Get print driver data (*)" },
+ { "getdriver", cmd_spoolss_not_implemented, "Get print driver information (*)" },
+ { "getdriverdir", cmd_spoolss_not_implemented, "Get print driver upload directory (*)" },
{ "getprinter", cmd_spoolss_getprinter, "Get printer info" },
-
+ { "openprinter", cmd_spoolss_open_printer_ex, "Open printer handle" },
{ NULL, NULL, NULL }
};
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 7cdd73a592..1b434dd696 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -116,7 +116,7 @@ static uint32 cmd_help(struct cli_state *cli, int argc, char **argv)
struct cmd_set *temp_set = temp_list->cmd_set;
while(temp_set->name) {
- printf("%s\t%s\n", temp_set->name,
+ printf("%15s\t\t%s\n", temp_set->name,
temp_set->description);
temp_set++;
}
@@ -149,14 +149,22 @@ static uint32 cmd_quit(struct cli_state *cli, int argc, char **argv)
/* Build in rpcclient commands */
static struct cmd_set rpcclient_commands[] = {
+ { "GENERAL OPTIONS", NULL, "" },
{ "help", cmd_help, "Print list of commands" },
+ { "?", cmd_help, "Print list of commands" },
{ "debuglevel", cmd_debuglevel, "Set debug level" },
+ { "exit", cmd_quit, "Exit program" },
{ "quit", cmd_quit, "Exit program" },
- { "?", cmd_help, "Print list of commands" },
{ NULL, NULL, NULL }
};
+static struct cmd_set separator_command[] = {
+ { "---------------", NULL, "----------------------" },
+ { NULL, NULL, NULL }
+};
+
+
void add_command_set(struct cmd_set *cmd_set)
{
struct cmd_list *entry;
@@ -213,11 +221,16 @@ static uint32 do_cmd(struct cli_state *cli, struct cmd_set *cmd_entry, char *cmd
}
/* Call the function */
+ if (cmd_entry->fn) {
+ result = cmd_entry->fn(cli, argc, argv);
+ }
+ else {
+ fprintf (stderr, "Invalid command\n");
+ result = NT_STATUS_INVALID_PARAMETER;
+ }
- result = cmd_entry->fn(cli, argc, argv);
-
+
/* Cleanup */
-
for (i = 0; i < argc; i++) {
free(argv[i]);
}
@@ -445,7 +458,7 @@ static void usage(char *pname)
*/
if (!got_pass) {
init_rpcclient_creds (&creds, username, workgroup, "");
- pwd_read(&creds.pwd, "Password : ", lp_encrypted_passwords());
+ pwd_read(&creds.pwd, "Enter Password: ", lp_encrypted_passwords());
}
else {
init_rpcclient_creds (&creds, username, workgroup, password);
@@ -464,9 +477,13 @@ static void usage(char *pname)
/* Load command lists */
add_command_set(rpcclient_commands);
+ add_command_set(separator_command);
add_command_set(spoolss_commands);
+ add_command_set(separator_command);
add_command_set(lsarpc_commands);
+ add_command_set(separator_command);
add_command_set(samr_commands);
+ add_command_set(separator_command);
/* Do anything specified with -c */