r85: Update the winbind interface version, as I just extended the struct.
[Samba/gebeck_regimport.git] / source3 / utils / net_rap.c
blob39254641abf9383010c0aef381d9f85badbbb130
1 /*
2 Samba Unix/Linux SMB client library
3 Distributed SMB/CIFS Server Management Utility
4 Copyright (C) 2001 Steve French (sfrench@us.ibm.com)
5 Copyright (C) 2001 Jim McDonough (jmcd@us.ibm.com)
6 Copyright (C) 2001 Andrew Tridgell (tridge@samba.org)
7 Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org)
9 Originally written by Steve and Jim. Largely rewritten by tridge in
10 November 2001.
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "includes.h"
27 #include "../utils/net.h"
29 /* The following messages were for error checking that is not properly
30 reported at the moment. Which should be reinstated? */
31 #define ERRMSG_TARGET_WG_NOT_VALID "\nTarget workgroup option not valid "\
32 "except on net rap server command, ignored"
33 #define ERRMSG_INVALID_HELP_OPTION "\nInvalid help option\n"
35 #define ERRMSG_BOTH_SERVER_IPADDRESS "\nTarget server and IP address both "\
36 "specified. Do not set both at the same time. The target IP address was used\n"
38 const char *share_type[] = {
39 "Disk",
40 "Print",
41 "Dev",
42 "IPC"
45 static int errmsg_not_implemented(void)
47 d_printf("\nNot implemented\n");
48 return 0;
51 int net_rap_file_usage(int argc, const char **argv)
53 return net_help_file(argc, argv);
56 /***************************************************************************
57 list info on an open file
58 ***************************************************************************/
59 static void file_fn(const char * pPath, const char * pUser, uint16 perms,
60 uint16 locks, uint32 id)
62 d_printf("%-7.1d %-20.20s 0x%-4.2x %-6.1d %s\n",
63 id, pUser, perms, locks, pPath);
66 static void one_file_fn(const char *pPath, const char *pUser, uint16 perms,
67 uint16 locks, uint32 id)
69 d_printf("File ID %d\n"\
70 "User name %s\n"\
71 "Locks 0x%-4.2x\n"\
72 "Path %s\n"\
73 "Permissions 0x%x\n",
74 id, pUser, locks, pPath, perms);
78 static int rap_file_close(int argc, const char **argv)
80 struct cli_state *cli;
81 int ret;
82 if (argc == 0) {
83 d_printf("\nMissing fileid of file to close\n\n");
84 return net_rap_file_usage(argc, argv);
87 if (!(cli = net_make_ipc_connection(0)))
88 return -1;
90 ret = cli_NetFileClose(cli, atoi(argv[0]));
91 cli_shutdown(cli);
92 return ret;
95 static int rap_file_info(int argc, const char **argv)
97 struct cli_state *cli;
98 int ret;
99 if (argc == 0)
100 return net_rap_file_usage(argc, argv);
102 if (!(cli = net_make_ipc_connection(0)))
103 return -1;
105 ret = cli_NetFileGetInfo(cli, atoi(argv[0]), one_file_fn);
106 cli_shutdown(cli);
107 return ret;
110 static int rap_file_user(int argc, const char **argv)
112 if (argc == 0)
113 return net_rap_file_usage(argc, argv);
115 d_printf("net rap file user not implemented yet\n");
116 return -1;
119 int net_rap_file(int argc, const char **argv)
121 struct functable func[] = {
122 {"CLOSE", rap_file_close},
123 {"USER", rap_file_user},
124 {"INFO", rap_file_info},
125 {NULL, NULL}
128 if (argc == 0) {
129 struct cli_state *cli;
130 int ret;
132 if (!(cli = net_make_ipc_connection(0)))
133 return -1;
135 /* list open files */
136 d_printf(
137 "\nEnumerating open files on remote server:\n\n"\
138 "\nFileId Opened by Perms Locks Path \n"\
139 "------ --------- ----- ----- ---- \n");
140 ret = cli_NetFileEnum(cli, NULL, NULL, file_fn);
141 cli_shutdown(cli);
142 return ret;
145 return net_run_function(argc, argv, func, net_rap_file_usage);
148 int net_rap_share_usage(int argc, const char **argv)
150 return net_help_share(argc, argv);
153 static void long_share_fn(const char *share_name, uint32 type,
154 const char *comment, void *state)
156 d_printf("%-12s %-8.8s %-50s\n",
157 share_name, share_type[type], comment);
160 static void share_fn(const char *share_name, uint32 type,
161 const char *comment, void *state)
163 d_printf("%s\n", share_name);
166 static int rap_share_delete(int argc, const char **argv)
168 struct cli_state *cli;
169 int ret;
171 if (argc == 0) {
172 d_printf("\n\nShare name not specified\n");
173 return net_rap_share_usage(argc, argv);
176 if (!(cli = net_make_ipc_connection(0)))
177 return -1;
179 ret = cli_NetShareDelete(cli, argv[0]);
180 cli_shutdown(cli);
181 return ret;
184 static int rap_share_add(int argc, const char **argv)
186 struct cli_state *cli;
187 int ret;
189 RAP_SHARE_INFO_2 sinfo;
190 char *p;
191 char *sharename;
193 if (argc == 0) {
194 d_printf("\n\nShare name not specified\n");
195 return net_rap_share_usage(argc, argv);
198 if (!(cli = net_make_ipc_connection(0)))
199 return -1;
201 sharename = strdup(argv[0]);
202 p = strchr(sharename, '=');
203 *p = 0;
204 strlcpy(sinfo.share_name, sharename, sizeof(sinfo.share_name));
205 sinfo.reserved1 = '\0';
206 sinfo.share_type = 0;
207 sinfo.comment = smb_xstrdup(opt_comment);
208 sinfo.perms = 0;
209 sinfo.maximum_users = opt_maxusers;
210 sinfo.active_users = 0;
211 sinfo.path = p+1;
212 memset(sinfo.password, '\0', sizeof(sinfo.password));
213 sinfo.reserved2 = '\0';
215 ret = cli_NetShareAdd(cli, &sinfo);
216 cli_shutdown(cli);
217 return ret;
221 int net_rap_share(int argc, const char **argv)
223 struct functable func[] = {
224 {"DELETE", rap_share_delete},
225 {"CLOSE", rap_share_delete},
226 {"ADD", rap_share_add},
227 {NULL, NULL}
230 if (argc == 0) {
231 struct cli_state *cli;
232 int ret;
234 if (!(cli = net_make_ipc_connection(0)))
235 return -1;
237 if (opt_long_list_entries) {
238 d_printf(
239 "\nEnumerating shared resources (exports) on remote server:\n\n"\
240 "\nShare name Type Description\n"\
241 "---------- ---- -----------\n");
242 ret = cli_RNetShareEnum(cli, long_share_fn, NULL);
243 } else {
244 ret = cli_RNetShareEnum(cli, share_fn, NULL);
246 cli_shutdown(cli);
247 return ret;
250 return net_run_function(argc, argv, func, net_rap_share_usage);
254 int net_rap_session_usage(int argc, const char **argv)
256 d_printf(
257 "\nnet rap session [misc. options] [targets]"\
258 "\n\tenumerates all active SMB/CIFS sessions on target server\n");
259 d_printf(
260 "\nnet rap session DELETE <client_name> [misc. options] [targets] \n"\
261 "\tor"\
262 "\nnet rap session CLOSE <client_name> [misc. options] [targets]"\
263 "\n\tDeletes (closes) a session from specified client to server\n");
264 d_printf(
265 "\nnet rap session INFO <client_name>"\
266 "\n\tEnumerates all open files in specified session\n");
268 net_common_flags_usage(argc, argv);
269 return -1;
272 static void list_sessions_func(char *wsname, char *username, uint16 conns,
273 uint16 opens, uint16 users, uint32 sess_time,
274 uint32 idle_time, uint32 user_flags, char *clitype)
276 int hrs = idle_time / 3600;
277 int min = (idle_time / 60) % 60;
278 int sec = idle_time % 60;
280 d_printf("\\\\%-18.18s %-20.20s %-18.18s %5d %2.2d:%2.2d:%2.2d\n",
281 wsname, username, clitype, opens, hrs, min, sec);
284 static void display_session_func(const char *wsname, const char *username,
285 uint16 conns, uint16 opens, uint16 users,
286 uint32 sess_time, uint32 idle_time,
287 uint32 user_flags, const char *clitype)
289 int ihrs = idle_time / 3600;
290 int imin = (idle_time / 60) % 60;
291 int isec = idle_time % 60;
292 int shrs = sess_time / 3600;
293 int smin = (sess_time / 60) % 60;
294 int ssec = sess_time % 60;
295 d_printf("User name %-20.20s\n"\
296 "Computer %-20.20s\n"\
297 "Guest logon %-20.20s\n"\
298 "Client Type %-40.40s\n"\
299 "Sess time %2.2d:%2.2d:%2.2d\n"\
300 "Idle time %2.2d:%2.2d:%2.2d\n",
301 username, wsname,
302 (user_flags&0x0)?"yes":"no", clitype,
303 shrs, smin, ssec, ihrs, imin, isec);
306 static void display_conns_func(uint16 conn_id, uint16 conn_type, uint16 opens,
307 uint16 users, uint32 conn_time,
308 const char *username, const char *netname)
310 d_printf("%-14.14s %-8.8s %5d\n",
311 netname, share_type[conn_type], opens);
314 static int rap_session_info(int argc, const char **argv)
316 const char *sessname;
317 struct cli_state *cli;
318 int ret;
320 if (!(cli = net_make_ipc_connection(0)))
321 return -1;
323 if (argc == 0)
324 return net_rap_session_usage(argc, argv);
326 sessname = argv[0];
328 ret = cli_NetSessionGetInfo(cli, sessname, display_session_func);
329 if (ret < 0) {
330 cli_shutdown(cli);
331 return ret;
334 d_printf("Share name Type # Opens\n-------------------------"\
335 "-----------------------------------------------------\n");
336 ret = cli_NetConnectionEnum(cli, sessname, display_conns_func);
337 cli_shutdown(cli);
338 return ret;
341 static int rap_session_delete(int argc, const char **argv)
343 struct cli_state *cli;
344 int ret;
346 if (!(cli = net_make_ipc_connection(0)))
347 return -1;
349 if (argc == 0)
350 return net_rap_session_usage(argc, argv);
352 ret = cli_NetSessionDel(cli, argv[0]);
353 cli_shutdown(cli);
354 return ret;
357 int net_rap_session(int argc, const char **argv)
359 struct functable func[] = {
360 {"INFO", rap_session_info},
361 {"DELETE", rap_session_delete},
362 {"CLOSE", rap_session_delete},
363 {NULL, NULL}
366 if (argc == 0) {
367 struct cli_state *cli;
368 int ret;
370 if (!(cli = net_make_ipc_connection(0)))
371 return -1;
373 d_printf("Computer User name "\
374 "Client Type Opens Idle time\n"\
375 "------------------------------------------"\
376 "------------------------------------\n");
377 ret = cli_NetSessionEnum(cli, list_sessions_func);
379 cli_shutdown(cli);
380 return ret;
383 return net_run_function(argc, argv, func, net_rap_session_usage);
386 /****************************************************************************
387 list a server name
388 ****************************************************************************/
389 static void display_server_func(const char *name, uint32 m,
390 const char *comment, void * reserved)
392 d_printf("\t%-16.16s %s\n", name, comment);
396 int net_rap_server_usage(int argc, const char **argv)
398 d_printf("net rap server [misc. options] [target]\n\t"\
399 "lists the servers in the specified domain or workgroup.\n");
400 d_printf("\n\tIf domain is not specified, it uses the current"\
401 " domain or workgroup as\n\tthe default.\n");
403 net_common_flags_usage(argc, argv);
404 return -1;
407 int net_rap_server(int argc, const char **argv)
409 struct cli_state *cli;
410 int ret;
412 if (!(cli = net_make_ipc_connection(0)))
413 return -1;
415 d_printf("\nEnumerating servers in this domain or workgroup: \n\n"\
416 "\tServer name Server description\n"\
417 "\t------------- ----------------------------\n");
419 ret = cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL,
420 display_server_func,NULL);
421 cli_shutdown(cli);
422 return ret;
425 int net_rap_domain_usage(int argc, const char **argv)
427 d_printf("net rap domain [misc. options] [target]\n\tlists the"\
428 " domains or workgroups visible on the current network\n");
430 net_common_flags_usage(argc, argv);
431 return -1;
435 int net_rap_domain(int argc, const char **argv)
437 struct cli_state *cli;
438 int ret;
440 if (!(cli = net_make_ipc_connection(0)))
441 return -1;
443 d_printf("\nEnumerating domains:\n\n"\
444 "\tDomain name Server name of Browse Master\n"\
445 "\t------------- ----------------------------\n");
447 ret = cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM,
448 display_server_func,NULL);
449 cli_shutdown(cli);
450 return ret;
453 int net_rap_printq_usage(int argc, const char **argv)
455 d_printf(
456 "net rap printq [misc. options] [targets]\n"\
457 "\tor\n"\
458 "net rap printq list [<queue_name>] [misc. options] [targets]\n"\
459 "\tlists the specified queue and jobs on the target server.\n"\
460 "\tIf the queue name is not specified, all queues are listed.\n\n");
461 d_printf(
462 "net rap printq delete [<queue name>] [misc. options] [targets]\n"\
463 "\tdeletes the specified job number on the target server, or the\n"\
464 "\tprinter queue if no job number is specified\n");
466 net_common_flags_usage(argc, argv);
468 return -1;
471 static void enum_queue(const char *queuename, uint16 pri, uint16 start,
472 uint16 until, const char *sep, const char *pproc,
473 const char *dest, const char *qparms,
474 const char *qcomment, uint16 status, uint16 jobcount)
476 d_printf("%-17.17s Queue %5d jobs ",
477 queuename, jobcount);
479 switch (status) {
480 case 0:
481 d_printf("*Printer Active*\n");
482 break;
483 case 1:
484 d_printf("*Printer Paused*\n");
485 break;
486 case 2:
487 d_printf("*Printer error*\n");
488 break;
489 case 3:
490 d_printf("*Delete Pending*\n");
491 break;
492 default:
493 d_printf("**UNKNOWN STATUS**\n");
497 static void enum_jobs(uint16 jobid, const char *ownername,
498 const char *notifyname, const char *datatype,
499 const char *jparms, uint16 pos, uint16 status,
500 const char *jstatus, unsigned int submitted, unsigned int jobsize,
501 const char *comment)
503 d_printf(" %-23.23s %5d %9d ",
504 ownername, jobid, jobsize);
505 switch (status) {
506 case 0:
507 d_printf("Waiting\n");
508 break;
509 case 1:
510 d_printf("Held in queue\n");
511 break;
512 case 2:
513 d_printf("Spooling\n");
514 break;
515 case 3:
516 d_printf("Printing\n");
517 break;
518 default:
519 d_printf("**UNKNOWN STATUS**\n");
523 #define PRINTQ_ENUM_DISPLAY \
524 "Print queues at \\\\%s\n\n"\
525 "Name Job # Size Status\n\n"\
526 "------------------------------------------------------------------"\
527 "-------------\n"
529 static int rap_printq_info(int argc, const char **argv)
531 struct cli_state *cli;
532 int ret;
534 if (argc == 0)
535 return net_rap_printq_usage(argc, argv);
537 if (!(cli = net_make_ipc_connection(0)))
538 return -1;
540 d_printf(PRINTQ_ENUM_DISPLAY, cli->desthost); /* list header */
541 ret = cli_NetPrintQGetInfo(cli, argv[0], enum_queue, enum_jobs);
542 cli_shutdown(cli);
543 return ret;
546 static int rap_printq_delete(int argc, const char **argv)
548 struct cli_state *cli;
549 int ret;
551 if (argc == 0)
552 return net_rap_printq_usage(argc, argv);
554 if (!(cli = net_make_ipc_connection(0)))
555 return -1;
557 ret = cli_printjob_del(cli, atoi(argv[0]));
558 cli_shutdown(cli);
559 return ret;
562 int net_rap_printq(int argc, const char **argv)
564 struct cli_state *cli;
565 int ret;
567 struct functable func[] = {
568 {"INFO", rap_printq_info},
569 {"DELETE", rap_printq_delete},
570 {NULL, NULL}
573 if (argc == 0) {
574 if (!(cli = net_make_ipc_connection(0)))
575 return -1;
577 d_printf(PRINTQ_ENUM_DISPLAY, cli->desthost); /* list header */
578 ret = cli_NetPrintQEnum(cli, enum_queue, enum_jobs);
579 cli_shutdown(cli);
580 return ret;
583 return net_run_function(argc, argv, func, net_rap_printq_usage);
587 static int net_rap_user_usage(int argc, const char **argv)
589 return net_help_user(argc, argv);
592 static void user_fn(const char *user_name, const char *comment,
593 const char * home_dir, const char * logon_script,
594 void *state)
596 d_printf("%-21.21s\n", user_name);
599 static void long_user_fn(const char *user_name, const char *comment,
600 const char * home_dir, const char * logon_script,
601 void *state)
603 d_printf("%-21.21s %s\n",
604 user_name, comment);
607 static void group_member_fn(const char *user_name, void *state)
609 d_printf("%-21.21s\n", user_name);
612 static int rap_user_delete(int argc, const char **argv)
614 struct cli_state *cli;
615 int ret;
617 if (argc == 0) {
618 d_printf("\n\nUser name not specified\n");
619 return net_rap_user_usage(argc, argv);
622 if (!(cli = net_make_ipc_connection(0)))
623 return -1;
625 ret = cli_NetUserDelete(cli, argv[0]);
626 cli_shutdown(cli);
627 return ret;
630 static int rap_user_add(int argc, const char **argv)
632 struct cli_state *cli;
633 int ret;
634 RAP_USER_INFO_1 userinfo;
636 if (argc == 0) {
637 d_printf("\n\nUser name not specified\n");
638 return net_rap_user_usage(argc, argv);
641 if (!(cli = net_make_ipc_connection(0)))
642 return -1;
644 safe_strcpy(userinfo.user_name, argv[0], sizeof(userinfo.user_name)-1);
645 if (opt_flags == -1)
646 opt_flags = 0x21;
648 userinfo.userflags = opt_flags;
649 userinfo.reserved1 = '\0';
650 userinfo.comment = smb_xstrdup(opt_comment);
651 userinfo.priv = 1;
652 userinfo.home_dir = NULL;
653 userinfo.logon_script = NULL;
655 ret = cli_NetUserAdd(cli, &userinfo);
657 cli_shutdown(cli);
658 return ret;
661 static int rap_user_info(int argc, const char **argv)
663 struct cli_state *cli;
664 int ret;
665 if (argc == 0) {
666 d_printf("\n\nUser name not specified\n");
667 return net_rap_user_usage(argc, argv);
670 if (!(cli = net_make_ipc_connection(0)))
671 return -1;
673 ret = cli_NetUserGetGroups(cli, argv[0], group_member_fn, NULL);
674 cli_shutdown(cli);
675 return ret;
678 int net_rap_user(int argc, const char **argv)
680 int ret = -1;
681 struct functable func[] = {
682 {"ADD", rap_user_add},
683 {"INFO", rap_user_info},
684 {"DELETE", rap_user_delete},
685 {NULL, NULL}
688 if (argc == 0) {
689 struct cli_state *cli;
690 if (!(cli = net_make_ipc_connection(0)))
691 goto done;
692 if (opt_long_list_entries) {
693 d_printf("\nUser name Comment"\
694 "\n-----------------------------\n");
695 ret = cli_RNetUserEnum(cli, long_user_fn, NULL);
696 cli_shutdown(cli);
697 goto done;
699 ret = cli_RNetUserEnum(cli, user_fn, NULL);
700 cli_shutdown(cli);
701 goto done;
704 ret = net_run_function(argc, argv, func, net_rap_user_usage);
705 done:
706 if (ret != 0) {
707 DEBUG(1, ("Net user returned: %d\n", ret));
709 return ret;
713 int net_rap_group_usage(int argc, const char **argv)
715 return net_help_group(argc, argv);
718 static void long_group_fn(const char *group_name, const char *comment,
719 void *state)
721 d_printf("%-21.21s %s\n", group_name, comment);
724 static void group_fn(const char *group_name, const char *comment, void *state)
726 d_printf("%-21.21s\n", group_name);
729 static int rap_group_delete(int argc, const char **argv)
731 struct cli_state *cli;
732 int ret;
733 if (argc == 0) {
734 d_printf("\n\nGroup name not specified\n");
735 return net_rap_group_usage(argc, argv);
738 if (!(cli = net_make_ipc_connection(0)))
739 return -1;
741 ret = cli_NetGroupDelete(cli, argv[0]);
742 cli_shutdown(cli);
743 return ret;
746 static int rap_group_add(int argc, const char **argv)
748 struct cli_state *cli;
749 int ret;
750 RAP_GROUP_INFO_1 grinfo;
752 if (argc == 0) {
753 d_printf("\n\nGroup name not specified\n");
754 return net_rap_group_usage(argc, argv);
757 if (!(cli = net_make_ipc_connection(0)))
758 return -1;
760 /* BB check for length 21 or smaller explicitly ? BB */
761 safe_strcpy(grinfo.group_name, argv[0], sizeof(grinfo.group_name)-1);
762 grinfo.reserved1 = '\0';
763 grinfo.comment = smb_xstrdup(opt_comment);
765 ret = cli_NetGroupAdd(cli, &grinfo);
766 cli_shutdown(cli);
767 return ret;
770 int net_rap_group(int argc, const char **argv)
772 struct functable func[] = {
773 {"ADD", rap_group_add},
774 {"DELETE", rap_group_delete},
775 {NULL, NULL}
778 if (argc == 0) {
779 struct cli_state *cli;
780 int ret;
781 if (!(cli = net_make_ipc_connection(0)))
782 return -1;
783 if (opt_long_list_entries) {
784 d_printf("Group name Comment\n");
785 d_printf("-----------------------------\n");
786 ret = cli_RNetGroupEnum(cli, long_group_fn, NULL);
787 cli_shutdown(cli);
788 return ret;
790 ret = cli_RNetGroupEnum(cli, group_fn, NULL);
791 cli_shutdown(cli);
792 return ret;
795 return net_run_function(argc, argv, func, net_rap_group_usage);
798 int net_rap_groupmember_usage(int argc, const char **argv)
800 d_printf(
801 "net rap groupmember LIST <group> [misc. options] [targets]"\
802 "\n\t Enumerate users in a group\n"\
803 "\nnet rap groupmember DELETE <group> <user> [misc. options] "\
804 "[targets]\n\t Delete sepcified user from specified group\n"\
805 "\nnet rap groupmember ADD <group> <user> [misc. options] [targets]"\
806 "\n\t Add specified user to specified group\n");
808 net_common_flags_usage(argc, argv);
809 return -1;
813 static int rap_groupmember_add(int argc, const char **argv)
815 struct cli_state *cli;
816 int ret;
817 if (argc != 2) {
818 d_printf("\n\nGroup or user name not specified\n");
819 return net_rap_groupmember_usage(argc, argv);
822 if (!(cli = net_make_ipc_connection(0)))
823 return -1;
825 ret = cli_NetGroupAddUser(cli, argv[0], argv[1]);
826 cli_shutdown(cli);
827 return ret;
830 static int rap_groupmember_delete(int argc, const char **argv)
832 struct cli_state *cli;
833 int ret;
834 if (argc != 2) {
835 d_printf("\n\nGroup or user name not specified\n");
836 return net_rap_groupmember_usage(argc, argv);
839 if (!(cli = net_make_ipc_connection(0)))
840 return -1;
842 ret = cli_NetGroupDelUser(cli, argv[0], argv[1]);
843 cli_shutdown(cli);
844 return ret;
847 static int rap_groupmember_list(int argc, const char **argv)
849 struct cli_state *cli;
850 int ret;
851 if (argc == 0) {
852 d_printf("\n\nGroup name not specified\n");
853 return net_rap_groupmember_usage(argc, argv);
856 if (!(cli = net_make_ipc_connection(0)))
857 return -1;
859 ret = cli_NetGroupGetUsers(cli, argv[0], group_member_fn, NULL );
860 cli_shutdown(cli);
861 return ret;
864 int net_rap_groupmember(int argc, const char **argv)
866 struct functable func[] = {
867 {"ADD", rap_groupmember_add},
868 {"LIST", rap_groupmember_list},
869 {"DELETE", rap_groupmember_delete},
870 {NULL, NULL}
873 return net_run_function(argc, argv, func, net_rap_groupmember_usage);
876 int net_rap_validate_usage(int argc, const char **argv)
878 d_printf("net rap validate <username> [password]\n"\
879 "\tValidate user and password to check whether they"\
880 " can access target server or domain\n");
882 net_common_flags_usage(argc, argv);
883 return -1;
886 int net_rap_validate(int argc, const char **argv)
888 return errmsg_not_implemented();
891 int net_rap_service_usage(int argc, const char **argv)
893 d_printf("net rap service [misc. options] [targets] \n"\
894 "\tlists all running service daemons on target server\n");
895 d_printf("\nnet rap service START <name> [service startup arguments]"\
896 " [misc. options] [targets]"\
897 "\n\tStart named service on remote server\n");
898 d_printf("\nnet rap service STOP <name> [misc. options] [targets]\n"\
899 "\n\tStop named service on remote server\n");
901 net_common_flags_usage(argc, argv);
902 return -1;
905 static int rap_service_start(int argc, const char **argv)
907 return errmsg_not_implemented();
910 static int rap_service_stop(int argc, const char **argv)
912 return errmsg_not_implemented();
915 int net_rap_service(int argc, const char **argv)
917 struct functable func[] = {
918 {"START", rap_service_start},
919 {"STOP", rap_service_stop},
920 {NULL, NULL}
923 if (argc == 0) {
924 struct cli_state *cli;
925 int ret;
926 if (!(cli = net_make_ipc_connection(0)))
927 return -1;
929 if (opt_long_list_entries) {
930 d_printf("Service name Comment\n");
931 d_printf("-----------------------------\n");
932 ret = cli_RNetServiceEnum(cli, long_group_fn, NULL);
934 ret = cli_RNetServiceEnum(cli, group_fn, NULL);
935 cli_shutdown(cli);
936 return ret;
939 return net_run_function(argc, argv, func, net_rap_service_usage);
942 int net_rap_password_usage(int argc, const char **argv)
944 d_printf(
945 "net rap password <user> <oldpwo> <newpw> [misc. options] [target]\n"\
946 "\tchanges the password for the specified user at target\n");
948 return -1;
952 int net_rap_password(int argc, const char **argv)
954 struct cli_state *cli;
955 int ret;
957 if (argc < 3)
958 return net_rap_password_usage(argc, argv);
960 if (!(cli = net_make_ipc_connection(0)))
961 return -1;
963 /* BB Add check for password lengths? */
964 ret = cli_oem_change_password(cli, argv[0], argv[2], argv[1]);
965 cli_shutdown(cli);
966 return ret;
969 int net_rap_admin_usage(int argc, const char **argv)
971 d_printf(
972 "net rap admin <remote command> [cmd args [env]] [misc. options] [targets]"\
973 "\n\texecutes a remote command on an os/2 target server\n");
975 return -1;
979 int net_rap_admin(int argc, const char **argv)
981 return errmsg_not_implemented();
984 /* The help subsystem for the RAP subcommand */
986 int net_rap_usage(int argc, const char **argv)
988 d_printf(" net rap domain \tto list domains \n"\
989 " net rap file \t\tto list open files on a server \n"\
990 " net rap group \tto list user groups \n"\
991 " net rap groupmember \tto list users in a group \n"\
992 " net rap password \tto change the password of a user\n"\
993 " net rap printq \tto list the print queues on a server\n"\
994 " net rap server \tto list servers in a domain\n"\
995 " net rap session \tto list clients with open sessions to a server\n"\
996 " net rap share \tto list shares exported by a server\n"\
997 " net rap user \t\tto list users\n"\
998 " net rap validate \tto check whether a user and the corresponding password are valid\n"\
999 " net rap help\n"\
1000 "\nType \"net help <option>\" to get more information on that option\n\n");
1002 net_common_flags_usage(argc, argv);
1003 return -1;
1007 handle "net rap help *" subcommands
1009 int net_rap_help(int argc, const char **argv)
1011 struct functable func[] = {
1012 {"FILE", net_rap_file_usage},
1013 {"SHARE", net_rap_share_usage},
1014 {"SESSION", net_rap_session_usage},
1015 {"SERVER", net_rap_server_usage},
1016 {"DOMAIN", net_rap_domain_usage},
1017 {"PRINTQ", net_rap_printq_usage},
1018 {"USER", net_rap_user_usage},
1019 {"GROUP", net_rap_group_usage},
1020 {"VALIDATE", net_rap_validate_usage},
1021 {"GROUPMEMBER", net_rap_groupmember_usage},
1022 {"ADMIN", net_rap_admin_usage},
1023 {"SERVICE", net_rap_service_usage},
1024 {"PASSWORD", net_rap_password_usage},
1025 {NULL, NULL}};
1027 return net_run_function(argc, argv, func, net_rap_usage);
1030 /* Entry-point for all the RAP functions. */
1032 int net_rap(int argc, const char **argv)
1034 struct functable func[] = {
1035 {"FILE", net_rap_file},
1036 {"SHARE", net_rap_share},
1037 {"SESSION", net_rap_session},
1038 {"SERVER", net_rap_server},
1039 {"DOMAIN", net_rap_domain},
1040 {"PRINTQ", net_rap_printq},
1041 {"USER", net_rap_user},
1042 {"GROUP", net_rap_group},
1043 {"VALIDATE", net_rap_validate},
1044 {"GROUPMEMBER", net_rap_groupmember},
1045 {"ADMIN", net_rap_admin},
1046 {"SERVICE", net_rap_service},
1047 {"PASSWORD", net_rap_password},
1048 {"HELP", net_rap_help},
1049 {NULL, NULL}
1052 return net_run_function(argc, argv, func, net_rap_usage);