diff options
author | attilio <attilio@FreeBSD.org> | 2013-03-09 12:45:36 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2013-03-09 12:45:36 +0000 |
commit | 63326e81a339a762e08d5303facf65cc9cea9b87 (patch) | |
tree | 21c1d4f35c98c9eb7c1dae4a3d9eedfb120cbd53 /usr.bin | |
parent | 359add023cede52e6b7a5d624d929f7331925364 (diff) | |
download | FreeBSD-src-63326e81a339a762e08d5303facf65cc9cea9b87.zip FreeBSD-src-63326e81a339a762e08d5303facf65cc9cea9b87.tar.gz |
Garbage collect NWFS and NCP bits which are now completely disconnected
from the tree since few months.
This patch is not targeted for MFC.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ncplist/Makefile | 9 | ||||
-rw-r--r-- | usr.bin/ncplist/ncplist.1 | 88 | ||||
-rw-r--r-- | usr.bin/ncplist/ncplist.c | 474 | ||||
-rw-r--r-- | usr.bin/ncplogin/Makefile | 11 | ||||
-rw-r--r-- | usr.bin/ncplogin/ncplogin.1 | 262 | ||||
-rw-r--r-- | usr.bin/ncplogin/ncplogin.c | 205 | ||||
-rw-r--r-- | usr.bin/ncplogin/ncplogout.1 | 56 |
7 files changed, 0 insertions, 1105 deletions
diff --git a/usr.bin/ncplist/Makefile b/usr.bin/ncplist/Makefile deleted file mode 100644 index fdddb6c..0000000 --- a/usr.bin/ncplist/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD$ - -PROG= ncplist -NO_WCAST_ALIGN= - -DPADD= ${LIBNCP} ${LIBIPX} -LDADD= -lncp -lipx - -.include <bsd.prog.mk> diff --git a/usr.bin/ncplist/ncplist.1 b/usr.bin/ncplist/ncplist.1 deleted file mode 100644 index 1c5eb89..0000000 --- a/usr.bin/ncplist/ncplist.1 +++ /dev/null @@ -1,88 +0,0 @@ -.\" $FreeBSD$ -.Dd January 21, 2010 -.Dt NCPLIST 1 -.Os -.Sh NAME -.Nm ncplist -.Nd "display various information about ncplib and NetWare servers" -.Sh SYNOPSIS -.Nm -.Ar command -.Op Ar arguments -.Sh DESCRIPTION -The -.Nm -utility displays the state of ncplib and NetWare servers. -The first argument -is a one-letter -.Ar command -that may be followed by -.Ar arguments . -.Pp -The commands are: -.Bl -tag -width indent -.It Ic b Ar server type Op Ar pattern -Lists bindery objects of -.Ar type -on a specified -.Ar server . -The -.Ar type -argument -can be one of the following: -.Pp -.Bl -tag -width ".Cm pserver" -offset indent -compact -.It Em Type -.Em Meaning -.It Cm user -bindery users -.It Cm group -bindery groups -.It Cm pserver -bindery print servers -.It Cm tree -tree name hosted by given server -.El -.Pp -Note that if you are not logged in to the specified server, -the list may be incomplete or empty. -.It Ic c -List active NCP connections on the local machine. -.It Ic s Op Ar server -Display -.Tn NetWare -servers known to a given -.Ar server . -If no server is specified, the nearest server will be used. -.It Ic u Ar server -Displays a list of users logged in on a given -.Ar server . -If you are not logged in to the specified server, -the list will be empty. -.It Ic q Ar server Op Ar pattern -Displays bindery queues on a given -.Ar server . -.It Ic v Ar server -Displays mounted volumes on a given -.Ar server . -.El -.Sh IMPLEMENTATION NOTES -This utility is provided mostly for educational purposes. -.Sh FILES -.Bl -tag -width /var/log/utx.log -compact -.It Pa ~/.nwfsrc -keeps description for each connection. -See -.Pa /usr/share/examples/nwclient/dot.nwfsrc -for details. -.El -.Sh HISTORY -The -.Nm -utility first appeared in -.Fx 4.0 . -.Sh AUTHORS -.An Boris Popov Aq bp@butya.kz , -.Aq rbp@chat.ru -.Sh BUGS -Please report any bugs to the author. diff --git a/usr.bin/ncplist/ncplist.c b/usr.bin/ncplist/ncplist.c deleted file mode 100644 index ae3d22c..0000000 --- a/usr.bin/ncplist/ncplist.c +++ /dev/null @@ -1,474 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> - -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/time.h> - -#include <grp.h> -#include <pwd.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include <netncp/ncp_lib.h> - -extern char *__progname; - -static struct ncp_conn_stat conndesc; - -static void help(void); -static void show_connlist(void); -static void show_serverlist(char *server); -static void show_userlist(char *server); -static void list_volumes(char *server); -static void str_trim_right(char *s, char c); - - -static int -ncp_get_connid(char *server, int justattach) -{ - int connid, error; - struct ncp_conn_loginfo li; - - connid = ncp_conn_find(server, NULL); - if (connid > 0) { - ncp_conn_getinfo(connid, &conndesc); - return connid; - } - if (!justattach) { - if (connid == -1) { - printf("You are not attached to server %s\n",server); - return -1; - } - printf("You are not attached to any server\n"); - return -1; - } - ncp_li_init(&li, 0, NULL); - if (server) { - ncp_li_setserver(&li, server); - error = ncp_find_fileserver(&li, AF_IPX, NULL); - if (error) { - printf("Could not find server %s\n", li.server); - return -1; - } - } else { - error = ncp_find_fileserver(&li, AF_IPX, NULL); - if (error) { - printf("Can't find any file server\n"); - return -1; - } - } - error = ncp_connect(&li, &connid); - if (error) { - printf("Can't attach to a nearest server\n"); - return -1; - } - ncp_conn_getinfo(connid, &conndesc); - return connid; -} - -static struct ncp_bitname conn_statenames [] = { - {NCPFL_INVALID, "invalid"}, - {NCPFL_LOGGED, "active"}, - {NCPFL_PERMANENT, "permanent"}, - {NCPFL_PRIMARY, "primary"}, - {0, NULL} -}; - -static void -str_trim_right(char *s, char c) -{ - int len; - - for (len = strlen(s) - 1; len > 0 && s[len] == c; len--) - s[len] = '\0'; -} - -void -show_connlist(void) -{ - void *p; - int cnt; - char buf[200]; - struct ncp_conn_stat *ncsp; - - printf("Active NCP connections:\n"); - p = ncp_conn_list(); - if (p == NULL) { - printf("None\n"); - return; - } - printf(" refid server:user(connid), owner:group(mode), refs, <state>\n"); - cnt = *(int*)p; - ncsp = (struct ncp_conn_stat*)(((int*)p)+1); - while (cnt--) { - printf("%6d %s:%s(%d), %s:%s(%o), %d, %s", - ncsp->connRef, ncsp->li.server,ncsp->user,ncsp->connid, - user_from_uid(ncsp->owner, 0), - group_from_gid(ncsp->group, 0), - ncsp->li.access_mode, - ncsp->ref_cnt, - ncp_printb(buf, ncsp->flags, conn_statenames)); - printf("\n"); - ncsp++; - } - free(p); - printf("\n"); -} - -void -show_serverlist(char *server) -{ - int found = 0, connid; - struct ncp_bindery_object obj; - const char *pattern = "*"; - - connid = ncp_get_connid(server, 1); - if (connid < 0) - return; - printf("Visible servers (from %s):\n", conndesc.li.server); - printf("Name Network Node Port\n"); - printf("----------------------------------------------- -------- ------------ ----\n"); - obj.object_id = 0xffffffff; - - while (ncp_scan_bindery_object(connid, obj.object_id, NCP_BINDERY_FSERVER, - pattern, &obj) == 0) { - struct nw_property prop; - struct ipx_addr *naddr = (struct ipx_addr *) ∝ - - found = 1; - printf("%-48s", obj.object_name); - - if (ncp_read_property_value(connid, NCP_BINDERY_FSERVER, - obj.object_name, 1, "NET_ADDRESS", - &prop) == 0) { - ipx_print_addr(naddr); - } - printf("\n"); - } - - if (!found) { - printf("No servers found\n"); - } - printf("\n"); -} - - -void -show_userlist(char *server) -{ - int connid, error, i; - struct ncp_file_server_info info; - struct ncp_bindery_object user; - time_t login_time; - struct ipx_addr addr; - u_int8_t conn_type; - - connid = ncp_get_connid(server, 0); - if (connid < 0) return; - if (ncp_get_file_server_information(connid, &info) != 0) { - perror("Could not get server information"); - return; - } - printf("User information for server %s\n",info.ServerName); - printf("\n%-6s%-21s%-27s%-12s\n" - "---------------------------------------------" - "---------------------------------\n", - "Conn", - "User name", - "Station Address", - "Login time"); - for (i = 1; i <= info.MaximumServiceConnections; i++) { - char name[49]; - name[48] = '\0'; - error = ncp_get_stations_logged_info(connid, i, &user, &login_time); - if (error) continue; - memset(&addr, 0, sizeof(addr)); - error = ncp_get_internet_address(connid, i, &addr, &conn_type); - if (error) continue; - memcpy(name, user.object_name, 48); - str_trim_right(name, ' '); - printf("%4d: %-20s ", i, name); - ipx_print_addr(&addr); - printf(" "); - printf("%s", ctime(&login_time)); - } - - return; -} - -static void -show_queuelist(char *server, char *patt) -{ - struct ncp_bindery_object q; - int found = 0, connid; - char default_pattern[] = "*"; - char *pattern = default_pattern; - - connid = ncp_get_connid(server, 1); - if (connid < 0) return; - if (patt != NULL) - pattern = patt; - ncp_str_upper(pattern); - - printf("\nServer: %s\n", server); - printf("%-52s%-10s\n" - "-----------------------------------------------" - "-------------\n", - "Print queue name", - "Queue ID"); - q.object_id = 0xffffffff; - - while (ncp_scan_bindery_object(connid, q.object_id, - NCP_BINDERY_PQUEUE, pattern, &q) == 0) - { - found = 1; - printf("%-52s", q.object_name); - printf("%08X\n", (unsigned int) q.object_id); - } - - if (!found) { - printf("No queues found\n"); - } - return; -} - -void -list_volumes(char *server) -{ - int found = 0, connid, i, error; - struct ncp_file_server_info si; - char volname[NCP_VOLNAME_LEN+1]; - - connid = ncp_get_connid(server, 1); - if (connid < 0) return; - - error = ncp_get_file_server_information(connid, &si); - if (error) { - ncp_error("Can't get information for server %s", error, server); - return; - } - - printf("\nMounted volumes on server %s:\n", server); - printf("Number Name\n"); - printf("------ -----------------------------------------------\n"); - - for(i = 0; i < si.NumberMountedVolumes; i++) { - if (NWGetVolumeName(connid, i, volname)) - continue; - found = 1; - printf("%6d %s\n", i, volname); - } - - if (!found) - printf("No volumes found ?\n"); - return; -} - -struct ncp_bind_type { - u_long type; - const char *name; -}; - -static struct ncp_bind_type btypes[] = { - {NCP_BINDERY_USER, "USER"}, - {NCP_BINDERY_UGROUP, "GROUP"}, - {NCP_BINDERY_PSERVER, "PSERVER"}, - {0x278, "TREE"}, - {0, NULL} -}; - -static void -list_bindery(char *server, char *type, char *patt) -{ - struct ncp_bindery_object q; - int i, found = 0, connid; - char default_pattern[] = "*"; - char *pattern = default_pattern; - u_long objtype; - - ncp_str_upper(type); - objtype = 0; - - for(i = 0; btypes[i].type; i++) { - if (strcmp(btypes[i].name, type) == 0) { - objtype = btypes[i].type; - break; - } - } - if (!objtype) { - printf("Bindery object of type %s is unknown\n", type); - return; - } - if (patt != NULL) - pattern = patt; - ncp_str_upper(pattern); - connid = ncp_get_connid(server, 1); - if (connid < 0) return; - - connid = ncp_get_connid(server, 1); - if (connid < 0) return; - - - printf("\nServer: %s\n", server); - printf("%-52s%-10s\n" - "-----------------------------------------------" - "-------------\n", - "Object name", - "Object ID"); - - q.object_id = 0xffffffff; - while (ncp_scan_bindery_object(connid, q.object_id, - objtype, pattern, &q) == 0) - { - found = 1; - printf("%-52s", q.object_name); - printf("%08X\n", (unsigned int) q.object_id); - } - - if (!found) { - printf("No bindery objects found\n"); - } - return; -} - -enum listop { - LO_NONE, LO_SERVERS, LO_QUEUES, LO_BINDERY, LO_USERS, LO_VOLUMES -}; - -#define MAX_ARGS 10 - -int -main(int argc, char *argv[]) -{ - int opt, nargs = 0, i; - enum listop what; - char *args[MAX_ARGS]; - - bzero(args, sizeof(args)); - - what = LO_NONE; - while ((opt = getopt(argc, argv, "h")) != -1) { - switch (opt) { - case 'h': case '?': - help(); - /*NOTREACHED */ - default: - help(); - return 1; - } - } - if (optind >= argc) - help(); - - if(ncp_initlib()) - exit(1); - - switch(argv[optind++][0]) { - case 'b': - what = LO_BINDERY; - nargs = 2; - break; - case 'c': - show_connlist(); - return 0; - case 's': - what = LO_SERVERS; - break; - case 'u': - what = LO_USERS; - nargs = 1; - break; - case 'q': - what = LO_QUEUES; - nargs = 1; - break; - case 'v': - what = LO_VOLUMES; - nargs = 1; - break; - default: - printf("Unknown command %s\n", argv[optind-1]); - help(); - } - for (i = 0; i < MAX_ARGS; i++) { - if (optind < argc) { - args[i] = argv[optind++]; - } else if (i < nargs) { - printf("Not enough arguments\n"); - help(); - return 1; - } else - break; - } - switch(what) { - case LO_SERVERS: - show_serverlist(args[0]); - break; - case LO_USERS: - show_userlist(args[0]); - break; - case LO_QUEUES: - show_queuelist(args[0], args[1]); - break; - case LO_VOLUMES: - list_volumes(args[0]); - break; - case LO_BINDERY: - list_bindery(args[0], args[1], args[2]); - break; - default: - help(); - } - return 0; -} - -static void -help(void) -{ - printf("\n"); - printf("usage: %s command [args]\n", __progname); - printf("where commands are:\n" - " b server user|group [pattern] list bindery objects on server\n" - " c display opened connections\n" - " s [server] display known servers\n" - " u server list logged-in users on server\n" - " q server [pattern] list print queues on server\n" - " v server list mounted volumes on a specified server\n" - "\n"); - exit(1); -} diff --git a/usr.bin/ncplogin/Makefile b/usr.bin/ncplogin/Makefile deleted file mode 100644 index 8795f29..0000000 --- a/usr.bin/ncplogin/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD$ - -PROG= ncplogin -MAN= ncplogin.1 ncplogout.1 - -LINKS= ${BINDIR}/ncplogin ${BINDIR}/ncplogout - -LDADD= -lncp -lipx -DPADD= ${LIBNCP} ${LIBIPX} - -.include <bsd.prog.mk> diff --git a/usr.bin/ncplogin/ncplogin.1 b/usr.bin/ncplogin/ncplogin.1 deleted file mode 100644 index 24b806a..0000000 --- a/usr.bin/ncplogin/ncplogin.1 +++ /dev/null @@ -1,262 +0,0 @@ -.\" $FreeBSD$ -.Dd September 15, 1999 -.Dt NCPLOGIN 1 -.Os -.Sh NAME -.Nm ncplogin -.Nd create permanent connection to a NetWare server -.Sh SYNOPSIS -.Nm -.Op Fl BCDN -.Op Fl S Ar server -.Op Fl U Ar user -.Op Fl A Ar host -.Op Fl I Ar level -.Op Fl M Ar mode -.Oo -.Fl O Xo -.Op Ar owner Ns -.Op : Ns Ar group -.Xc -.Oc -.Op Fl R Ar retrycount -.Op Fl T Ar tree -.Op Fl W Ar timeout -.Nm -.Op Fl BCDN -.Op Fl A Ar host -.Op Fl I Ar level -.Op Fl M Ar mode -.Oo -.Fl O Xo -.Op Ar owner Ns -.Op : Ns Ar group -.Xc -.Oc -.Op Fl R Ar retrycount -.Op Fl T Ar tree -.Op Fl W Ar timeout -.No / Ns Ar server Ns : Ns Ar user -.Sh DESCRIPTION -Connections to a -.Tn NetWare -server can be created and used independently of the -.Xr mount_nwfs 8 -command. -Connections can be created by any user. -Each user can have multiple -connections, but each -.Ar NetWareServer Ns : Ns Ar NetWareUser -pair should be unique. -.Pp -The -.Nm -command is used to create a permanent connection to a -.Tn NetWare -server. -Permanent connections will stay open even if no application uses them. -This allows users to run different -.Pa ncp* -programs -without specifying a file server and user to use. -Established connections can be destroyed with the -.Xr ncplogout 1 -command. -.Pp -Upper case options described in this manual page -are common for other -.Pa ncp* -programs and are referred to as -.Dq connection options . -Options -.Fl U -and -.Fl S -are mutually exclusive with the -.No / Ns Ar server Ns : Ns Ar user -syntax. -.Pp -The following options are available: -.Bl -tag -width indent -.It Fl S Ar server -Specify the name of the -.Tn NetWare -server to connect to. -This affects only -.Tn IPX -servers. -For servers supporting -.Tn IP -natively, see the -.Fl A -option. -.It Fl U Ar user -Specify the name of the user used in the login sequence. -.It Fl A Ar host -Use the -.Tn UDP -protocol to connect to a -.Tn NetWare -5.x server specified by the -.Ar host -argument. -.It Fl C -Do not convert the password to uppercase. -.It Fl D -Mark the connection as primary. -The option can be used to modify existing connections. -Only the -.Nm -program accepts this option. -.It Fl I Ar signature_level -Try to use -.Ar signature_level . -Available values are: -.Pp -.Bl -tag -width ".Em Value" -offset indent -compact -.It Em Value -.Em Meaning -.It 0 -disable signatures -.It 1 -enable (use if required by server) -.It 2 -request but do not require signing -.It 3 -require signatures -.El -.Pp -Note that only packet header signing is implemented. -.It Fl M Ar mode -Share this connection. -The bits in the -.Ar mode -argument are similar to standard file permissions: -.Pp -.Bl -tag -width ".Em Mask" -offset indent -compact -.It Em Mask -.Em Meaning -.It 4 -.Pq READ -connection will be visible. -.It 2 -.Pq WRITE -connection can be closed/modified. -.It 1 -.Pq EXECUTE -user is allowed to execute requests. -.El -.Pp -By default, the connection is created with -.Ar mode -0700 -and only the owner can use it. -Specifying 0750 as the argument to the -.Fl M -option would allow read-only group access as well. -This would allow the group to perform -.Tn NCP -requests, -but not to destroy the connection. -When a server is not explicitly specified, -.Pa ncp* -programs try to find a suitable connection in the following order: -.Bl -enum -offset indent -.It -Try to find a connection owned by the user. -If there is more than one such -connection, try to determine which one is primary. -(The primary flag is set with the -.Fl D -option.) -.It -If the primary connection could not be determined, -the first shared connection will be used. -.El -.It Fl N -Do not prompt for a password. -At run time, -.Nm -reads the -.Pa ~/.nwfsrc -file for additional configuration parameters and a password. -If no password is found for the specified -.Ar server Ns : Ns Ar user -pair, -.Nm -prompts for it. -.It Fl O -Specify the -.Ar owner -and -.Ar group -attributes for the connection. -By default, newly created connections take the -.Ar owner -attribute from the creating user's username and the -.Ar group -attribute from the creating user's primary group. -This option overrides that behaviour. -Only the superuser can override the -.Ar owner -attribute for a connection. -.It Fl P -Mark the connection as permanent. -The -.Nm -utility always creates permanent connections. -This option can be useful in other -.Pa ncp* -programs. -.It Fl R Ar retry_count -Specify the number of retries to be performed -before dropping the connection. -The default value is 10. -.Pp -Note: after a connection is marked -.Dq BAD , -each request will try to restore it. -This process restores only the -.Tn NCP -connection; -it does not reopen any files that were open -at the time that the connection was marked -.Dq BAD . -.It Fl W Ar timeout -Specify the server request timeout in seconds. -The default is 5 seconds. -.It / Ns Ar server Ns : Ns Ar user -This syntax is provided for the sake of simplicity -and is mutually exclusive with the -.Fl S -and -.Fl U -options. -.El -.Sh IMPLEMENTATION NOTES -Low-level connection management is implemented in the -.Pa ncp.ko -kernel module. -The -.Xr IPXrouted 8 -program is also required for -.Tn IPX -support. -.Sh FILES -.Bl -tag -width ".Pa ~/.nwfsrc" -.It Pa ~/.nwfsrc -keeps static parameters for connections and other information; -see -.Pa /usr/share/examples/nwclient/dot.nwfsrc -for details. -.El -.Sh HISTORY -The -.Nm -command first appeared in -.Fx 4.0 . -.Sh AUTHORS -.An Boris Popov Aq bp@butya.kz , -.Aq rbp@chat.ru -.Sh BUGS -Please report any bugs to the author. diff --git a/usr.bin/ncplogin/ncplogin.c b/usr.bin/ncplogin/ncplogin.c deleted file mode 100644 index e64f63a..0000000 --- a/usr.bin/ncplogin/ncplogin.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> - -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/errno.h> -#include <sys/stat.h> - -#include <err.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sysexits.h> -#include <unistd.h> - -#include <netncp/ncp_lib.h> -#include <netncp/ncp_rcfile.h> - -extern char *__progname; - -static void -login_usage(void) { - printf("usage: %s [-Dh] [-A host] [-BCN] [-I level] [-M mode] \n" - " [-R retrycount] [-W timeout] /server:user\n", __progname); - exit(1); -} - -static void -logout_usage(void) { - printf("usage: %s [-c handle] [-h] [/server:user]\n", __progname); - exit(1); -} - -static void -login(int argc, char *argv[], struct ncp_conn_loginfo *li) { - int error = 0, connid, opt, setprimary = 0; - - while ((opt = getopt(argc, argv, STDPARAM_OPT"D")) != -1) { - switch(opt){ - case STDPARAM_ARGS: - if (ncp_li_arg(li, opt, optarg)) - exit(1); - break; - case 'D': - setprimary = 1; - break; - default: - login_usage(); - /*NOTREACHED*/ - } - } - if (li->access_mode == 0) - li->access_mode = S_IRWXU; - if (ncp_li_check(li)) - exit(1); - li->opt |= NCP_OPT_WDOG | NCP_OPT_PERMANENT; - /* now we can try to login, or use already established connection */ - error = ncp_li_login(li, &connid); - if (error) { - ncp_error("Could not login to server %s", error, li->server); - exit(1); - } - error = ncp_setpermanent(connid, 1); - if (error && errno != EACCES){ - ncp_error("Can't make connection permanent", error); - exit(1); - } - if (setprimary && ncp_setprimary(connid, 1) != 0) - ncp_error("Warning: can't make connection primary", errno); - printf("Logged in with conn handle:%d\n", connid); - return; -} - -static void -logout(int argc, char *argv[], struct ncp_conn_loginfo *li) { - int error = 0, connid, opt; - - connid = -1; - while ((opt = getopt(argc, argv, STDPARAM_OPT"c:")) != -1){ - switch (opt) { - case 'c': - connid = atoi(optarg); - break; - case STDPARAM_ARGS: - if (ncp_li_arg(li, opt, optarg)) - exit(1); - break; - default: - logout_usage(); - /*NOTREACHED*/ - } - } - if (connid == -1) { - if (li->server[0] == 0) - errx(EX_USAGE, "no server name specified"); - if (li->user == 0) - errx(EX_USAGE, "no user name specified"); - if (ncp_conn_scan(li, &connid)) - errx(EX_OSERR, "You are not attached to server %s", - li->server); - } - if (ncp_setpermanent(connid, 0) < 0 && errno != EACCES) { - ncp_error("Connection isn't valid", errno); - exit(EX_OSERR); - } - error = ncp_disconnect(connid); - if (error) { - if (errno == EACCES) { - warnx("you logged out, but connection belongs" - "to other user and not closed"); - } else { - ncp_error("Can't logout with connid %d", error, connid); - error = 1; - } - } - exit(error ? 1 : 0); -} - -int -main(int argc, char *argv[]) { - int islogin, error; - char *p, *p1; - struct ncp_conn_loginfo li; - - islogin = strcmp(__progname, "ncplogin") == 0; - - if (argc == 2) { - if (strcmp(argv[1], "-h") == 0) { - if (islogin) - login_usage(); - else - logout_usage(); - } - } - - if (ncp_initlib()) - exit(1); - if (ncp_li_init(&li, argc, argv)) - return 1; - - if (argc >= 2 && argv[argc - 1][0] == '/') { - p = argv[argc - 1]; - error = 1; - do { - if (*p++ != '/') - break; - p1 = strchr(p, ':'); - if (p1 == NULL) - break; - *p1++ = 0; - if (ncp_li_setserver(&li, p)) - break; - if (*p1 == 0) - break; - if (ncp_li_setuser(&li, p1)) break; - error = 0; - } while(0); - if (error) - errx(EX_DATAERR, - "an error occurred while parsing '%s'", - argv[argc - 1]); - } - - if (ncp_li_readrc(&li)) - return 1; - if (ncp_rc) - rc_close(ncp_rc); - if (islogin) - login(argc, argv, &li); - else - logout(argc, argv, &li); - return 0; -} diff --git a/usr.bin/ncplogin/ncplogout.1 b/usr.bin/ncplogin/ncplogout.1 deleted file mode 100644 index 14acaf5..0000000 --- a/usr.bin/ncplogin/ncplogout.1 +++ /dev/null @@ -1,56 +0,0 @@ -.\" $FreeBSD$ -.Dd September 15, 1999 -.Dt NCPLOGOUT 1 -.Os -.Sh NAME -.Nm ncplogout -.Nd schedule permanent connection to close -.Sh SYNOPSIS -.Nm -.Op Fl S Ar server -.Op Fl U Ar user -.Op Fl c Ar handle -.Nm -.Op Fl c Ar handle -.No / Ns Ar server Ns : Ns Ar user -.Sh DESCRIPTION -The -.Nm -utility will schedule a connection created by -.Xr ncplogin 1 -command to be closed. -If the connection is busy (i.e., used by other processes) it will -be closed when the last process using it is terminated. -This command is similar to the -.Tn DOS -.Pa logout.exe -command. -.Pp -The options are: -.Bl -tag -width indent -.It Fl S Ar server -Specify the name of the -.Tn NetWare -server to which the connection should be terminated. -Can be omitted if there is only -one connection active. -.It Fl U Ar user -Specify the name of the user to use when identifying the connection. -Can be omitted if there is only -one connection active. -.It Fl c Ar handle -Close a connection by handle. -A list of available handles can be obtained with the following command: -.Pp -.Dl "ncplist c" -.El -.Sh HISTORY -The -.Nm -utility first appeared in -.Fx 4.0 . -.Sh AUTHORS -.An Boris Popov Aq bp@butya.kz , -.Aq bp@FreeBSD.org -.Sh BUGS -Please report any bugs to the author. |