diff --git a/.downloads/ncpfs-2.0.8.tgz b/.downloads/ncpfs-2.0.8.tgz new file mode 100644 index 0000000..b808541 Binary files /dev/null and b/.downloads/ncpfs-2.0.8.tgz differ diff --git a/Changes b/Changes index ac367b8..7350721 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,12 @@ I only began this file with ncpfs-0.12. If you're interested in older versions, you can find them on ftp.gwdg.de:/pub/linux/misc/ncpfs/old. +ncpfs-2.0.7 -> ncpfs-2.0.8 +- Fixed util/Makefile for easier optimization handling. Thanks to Rik + Faith for this one +- added nwfstime. You can now set the file server date and time from Linux. +- added the contrib directory. Feel free to add more! + ncpfs-2.0.6 -> ncpfs-2.0.7 - Hopefully removed one security problem in ncpumount. - Added command line flag to pserver.c diff --git a/Makefile b/Makefile index 3f6f699..7a74f76 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Makefile for the linux ncp-filesystem routines. # -VERSION = 2.0.7 +VERSION = 2.0.8 # If you are using kerneld to autoload ncp support, # uncomment this (kerneld is in linux since about 1.3.57): @@ -28,10 +28,9 @@ SUBDIRS += kernel-1.2/src INCLUDES += -I$(TOPDIR)/kernel-1.2 endif -CFLAGS = -Wall $(INCLUDES) $(KERNELD) -DNCPFS_VERSION=\"$(VERSION)\" - -#CFLAGS += -g -CFLAGS += -O2 +COPT = -O2 +# COPT += -g +CFLAGS = $(COPT) -Wall $(INCLUDES) $(KERNELD) -DNCPFS_VERSION=\"$(VERSION)\" export INCLUDES BINDIR SBINDIR KERNELD VERSION HAVE_ELF CFLAGS @@ -58,7 +57,7 @@ install: clean_me: rm -f `find -name '*.out'` rm -f `find -name '*~'` - rm -f ncpfs.tgz + rm -f *.tgz clean: clean_me for i in $(SUBDIRS); do make -C $$i clean; done diff --git a/contrib/tknwmsg/nwmsg.c b/contrib/tknwmsg/nwmsg.c new file mode 100644 index 0000000..640b4b4 --- /dev/null +++ b/contrib/tknwmsg/nwmsg.c @@ -0,0 +1,239 @@ +/* + * nwmsg.c + * + * Fetch NetWare broadcast messages and write to the user + * + * Copyright (C) 1996 by Volker Lendecke + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ncplib.h" + +static int search_utmp(char *user, char *tty); + +static char *progname; + +void +main(int argc, char *argv[]) +{ + struct ncp_conn *conn; + char message[256]; + + char *mount_point; + struct ncp_fs_info info; + struct passwd *pwd; + char tty[256]; + char tty_path[256]; + FILE *tty_file; + FILE *mtab; + struct mntent *mnt; + long err; + + char tknwmsg_command[256]; + int error_level; + + + progname = argv[0]; + + openlog("nwmsg", LOG_PID, LOG_LPR); + + if (argc != 2) + { + fprintf(stderr, "usage: %s mount-point\n", + progname); + exit(1); + } + + mount_point = argv[1]; + if ((conn = ncp_open_mount(mount_point, &err)) == NULL) + { + com_err(progname, err, "in ncp_open_mount"); + exit(1); + } + + if (ncp_get_broadcast_message(conn, message) != 0) + { + fprintf(stderr, "%s: could not get broadcast message\n", + progname); + ncp_close(conn); + exit(1); + } + + if (strlen(message) == 0) + { + syslog(LOG_DEBUG, "no message"); + exit(0); + } + +#if 0 + syslog(LOG_DEBUG, "message: %s", message); +#endif + + info.version = NCP_GET_FS_INFO_VERSION; + if (ioctl(conn->mount_fid, NCP_IOC_GET_FS_INFO, &info) < 0) + { + fprintf(stderr, "%s: could not ioctl on connection: %s\n", + progname, strerror(errno)); + ncp_close(conn); + exit(1); + } + + ncp_close(conn); + + if ((pwd = getpwuid(info.mounted_uid)) == NULL) + { + fprintf(stderr, "%s: user %d not known\n", + progname, info.mounted_uid); + exit(1); + } + + if ((mtab = fopen(MOUNTED, "r")) == NULL) + { + fprintf(stderr, "%s: can't open %s\n", + progname, MOUNTED); + exit(1); + } + + while ((mnt = getmntent(mtab)) != NULL) + { + if (strcmp(mnt->mnt_dir, mount_point) == 0) + { + break; + } + } + + if (mnt == NULL) + { + syslog(LOG_DEBUG, "cannot find mtab entry\n"); + } + + if (search_utmp(pwd->pw_name, tty) != 0) + { + exit(1); + } + + sprintf(tty_path, "/dev/%s", tty); + if ((tty_file = fopen(tty_path, "w")) == NULL) + { + fprintf(stderr, "%s: cannot open %s: %s\n", + progname, tty_path, strerror(errno)); + exit(1); + } + + fprintf(tty_file,"\r\n\007\007\007Message from NetWare Server: %s\r\n", + mnt->mnt_fsname); + fprintf(tty_file, "%s\r\n", message); + + + //formulate the full system command for the X notice... + strcat(tknwmsg_command,"/usr/bin/tknwmsg -display :0 "); + strcat(tknwmsg_command,"Message from NetWare Server: "); + strcat(tknwmsg_command,mnt->mnt_fsname); + strcat(tknwmsg_command," "); + strcat(tknwmsg_command,message); + strcat(tknwmsg_command," &"); + + //execute this system command... + error_level = system(tknwmsg_command); + + + fclose(tty_file); + fclose(mtab); + return; +} + +/* The following routines have been taken from util-linux-2.5's write.c */ + +/* + * term_chk - check that a terminal exists, and get the message bit + * and the access time + */ +static int +term_chk(char *tty, int *msgsokP, time_t *atimeP, int *showerror) +{ + struct stat s; + char path[MAXPATHLEN]; + + (void)sprintf(path, "/dev/%s", tty); + if (stat(path, &s) < 0) { + if (showerror) + (void)fprintf(stderr, + "write: %s: %s\n", path, strerror(errno)); + return(1); + } + *msgsokP = (s.st_mode & (S_IWRITE >> 3)) != 0; /* group write bit */ + *atimeP = s.st_atime; + return(0); +} + +/* + * search_utmp - search utmp for the "best" terminal to write to + * + * Ignores terminals with messages disabled, and of the rest, returns + * the one with the most recent access time. Returns as value the number + * of the user's terminals with messages enabled, or -1 if the user is + * not logged in at all. + * + * Special case for writing to yourself - ignore the terminal you're + * writing from, unless that's the only terminal with messages enabled. + */ +static int +search_utmp(char *user, char *tty) +{ + struct utmp u; + time_t bestatime, atime; + int ufd, nloggedttys, nttys, msgsok, user_is_me; + + char atty[sizeof(u.ut_line) + 1]; + + if ((ufd = open(_PATH_UTMP, O_RDONLY)) < 0) { + perror("utmp"); + return -1; + } + + nloggedttys = nttys = 0; + bestatime = 0; + user_is_me = 0; + while (read(ufd, (char *) &u, sizeof(u)) == sizeof(u)) + if (strncmp(user, u.ut_name, sizeof(u.ut_name)) == 0) { + ++nloggedttys; + + (void)strncpy(atty, u.ut_line, sizeof(u.ut_line)); + atty[sizeof(u.ut_line)] = '\0'; + + if (term_chk(atty, &msgsok, &atime, 0)) + continue; /* bad term? skip */ + if (!msgsok) + continue; /* skip ttys with msgs off */ + + if (u.ut_type != USER_PROCESS) + continue; /* it's not a valid entry */ + + ++nttys; + if (atime > bestatime) { + bestatime = atime; + (void)strcpy(tty, atty); + } + } + + (void)close(ufd); + if (nloggedttys == 0) { + (void)fprintf(stderr, "write: %s is not logged in\n", user); + return -1; + } + return 0; +} diff --git a/contrib/tknwmsg/tknwmsg b/contrib/tknwmsg/tknwmsg new file mode 100755 index 0000000..a1371f7 --- /dev/null +++ b/contrib/tknwmsg/tknwmsg @@ -0,0 +1,57 @@ +#!/usr/bin/wish + +#This is a procedure for centering windows... +# +# +proc center {window_to_center} { + + update idletasks + + set width [expr [winfo reqwidth $window_to_center]] + set height [expr [winfo reqheight $window_to_center]] + + if {$width < 400} {set width 400} + + set x [expr [winfo screenwidth $window_to_center]/2 - $width/2] + set y [expr [winfo screenheight $window_to_center]/2 - $height/2] + + wm geometry $window_to_center $width\x$height+$x+$y + + #update idletasks + wm deiconify $window_to_center + +} + + +# +# +# +# +#This is the main() proc... + +set argv_exist [string length $argv] +if {$argv_exist <= 0} {puts "syntax: tkmesg string\a";exit} + + +wm withdraw . +wm title . "Netware Client for Linux" +wm resizable . 0 0 + +puts "\a" + +label .mesg -text $argv +pack .mesg -padx 5 -pady 5 + +button .ok -text "Ok" -command exit -width 5 +pack .ok -padx 5 -pady 5 + +focus .ok +bind .ok exit + + +center . + +#beep the users console after the window appears... +set ofd [open /dev/console w] +puts $ofd "\a" +close $ofd diff --git a/contrib/tknwmsg/tknwmsg.gif b/contrib/tknwmsg/tknwmsg.gif new file mode 100644 index 0000000..131519c Binary files /dev/null and b/contrib/tknwmsg/tknwmsg.gif differ diff --git a/contrib/tknwmsg/tknwmsg.html b/contrib/tknwmsg/tknwmsg.html new file mode 100644 index 0000000..b1b2b70 --- /dev/null +++ b/contrib/tknwmsg/tknwmsg.html @@ -0,0 +1,29 @@ + + + + + + + + +

Tknwmsg

+ +

Recieve NetWare broadcasts in a dialog under Linux.

+ +

The original source was included in the ncpfs package distributed on +sunsite.unc.edu. The modified source to nwmsg.c and a tcl/tk script can +be downloaded here. The tknwmsg_README is +also available for download.

+ +

The only requirements for installation are a system with tcl/tk installed +and X running. The system() command will fail if X is not running.

+ +

+


+ +

Kevin Burton

+ +

http://www.gl.umbc.edu/~kburto1/kburto1.html

+ + + diff --git a/contrib/tknwmsg/tknwmsg_README b/contrib/tknwmsg/tknwmsg_README new file mode 100644 index 0000000..23d5b4d --- /dev/null +++ b/contrib/tknwmsg/tknwmsg_README @@ -0,0 +1,40 @@ +Tknwmsg 1.0 for NCPFS. + +Kevin Burton (kburto1@umbc.edu), Copyright 1996 +Distributed under GPL (GNU Public License) + +-- INTRO -- + +Tknwmesg is a extension for ncpfs for linux that allows users to recived messages +while under an X console. + +Essentially it is an extension for nwmsg that comes with ncpfs. The only +changes are a system() call to a tk script that will run a dialog with an "ok" +button under X. + +-- INSTALLATION -- +TCL/TK must be installed on your system. If they are not then you will have to +get the source for their installation if you want to run tkmesg. + + - Download ncpfs from sunsite.unc.edu + - Run "su" to become root if you are not already root. + - Unpack ncpfs in a temporary directory. + - copy the Tknwmsg nwmsg.c to util/nwmsg.c in your ncpfs directory. + - copy tknwmsg to /usr/bin + - change to your nwmsg directory. + - run "make all;make install" and the new version of tknwmsg will be + installed. + +-- USE -- + + - At least 1 terminal on the local system must be have "mesg y". Else + no GUI dialog will be displayed. + + Using mesg y in a .bashrc will not work. The only way that I have + found to do this is to have chmod a+w /dev/ttyp? in Xsession or + $HOME/.xsession. Also it may be necessary to have .bashrc do the + same thing if users are starting and stopping xterms. + + + + diff --git a/include/ncplib.h b/include/ncplib.h index 3fc078e..ebc637b 100644 --- a/include/ncplib.h +++ b/include/ncplib.h @@ -158,6 +158,8 @@ ncp_get_file_server_description_strings(struct ncp_conn *conn, long ncp_get_file_server_time(struct ncp_conn *conn, time_t *target); +long +ncp_set_file_server_time(struct ncp_conn *conn, time_t *source); struct ncp_file_server_info { __u8 ServerName[48] __attribute__ ((packed)); diff --git a/lib/ncplib.c b/lib/ncplib.c index f152e20..7ff183a 100644 --- a/lib/ncplib.c +++ b/lib/ncplib.c @@ -1660,6 +1660,32 @@ ncp_get_file_server_time(struct ncp_conn *conn, time_t *target) return 0; } +long +ncp_set_file_server_time(struct ncp_conn *conn, time_t *source) +{ + long result; + int year; + struct tm *utime = localtime(source); + + year = utime->tm_year; + if (year > 99) + { + year -= 100; + } + + ncp_init_request_s(conn, 202); + ncp_add_byte(conn, year); + ncp_add_byte(conn, utime->tm_mon+1); + ncp_add_byte(conn, utime->tm_mday); + ncp_add_byte(conn, utime->tm_hour); + ncp_add_byte(conn, utime->tm_min); + ncp_add_byte(conn, utime->tm_sec); + + result = ncp_request(conn, 23); + ncp_unlock_conn(conn); + return result; +} + long ncp_get_file_server_information(struct ncp_conn *conn, struct ncp_file_server_info *target) diff --git a/man/nwfstime.1 b/man/nwfstime.1 new file mode 100644 index 0000000..c8d8f94 --- /dev/null +++ b/man/nwfstime.1 @@ -0,0 +1,85 @@ +.TH NWFSTIME 1 12/10/1996 nwfstime nwfstime +.SH NAME +nwfstime \- Display / Set a NetWare server's date and time +.SH SYNOPSIS +.B nwfstime +[ +.B -h +] [ +.B -S +.I server +] [ +.B -U +.I user name +] [ +.B -P +.I password + | +.B -n +] [ +.B -C +] [ +.B -s +] + +.SH DESCRIPTION +.B nwfstime +displays a NetWare server's date and time. You can also set a NetWare +server's date and time from the local time. + +.SH OPTIONS + +.B -h +.RS 3 +With -h nwfstime prints a little help text. +.RE + +.B -S +.I server +.RS 3 +is the name of the server you want to use. +.RE + +.B -U +.I user +.RS 3 +.B user +is the user name to use for login. To set the server's time, you need +supervisor privileges. +.RE + +.B -P +.I password +.RS 3 +.B password +is the password to use for login. If neither +.B -n +nor +.B -P +are given, and the user has no open connection to the server, nwfstime +prompts for a password. +.RE + +.B -n +.RS 3 +.B -n +should be given if no password is required for the login. As you need +supervisor privileges for setting the date and time, this option is +probably not used very often. +.RE + +.B -C +.RS 3 +By default, passwords are converted to uppercase before they are sent +to the server, because most servers require this. You can turn off +this conversion by +.B -C. +.RE + +.B -s +.RS 3 +With +.B -s, +nwfstime sets the file server's date and time according to the local +date and time. +.RE diff --git a/ncpfs-2.0.7.lsm b/ncpfs-2.0.8.lsm similarity index 83% rename from ncpfs-2.0.7.lsm rename to ncpfs-2.0.8.lsm index 2cd938c..62f3ce0 100644 --- a/ncpfs-2.0.7.lsm +++ b/ncpfs-2.0.8.lsm @@ -1,7 +1,7 @@ Begin3 Title: ncpfs -Version: 2.0.7 -Entered-date: 27. October 1996 +Version: 2.0.8 +Entered-date: 10. December 1996 Description: With ncpfs you can mount volumes of your netware server under Linux. You can also print to netware print queues and spool netware print queues to the @@ -13,7 +13,7 @@ Author: lendecke@namu01.Num.Math.Uni-Goettingen.de (Volker Lendecke) Maintained-by: lendecke@namu01.Num.Math.Uni-Goettingen.de (Volker Lendecke) Primary-site: ftp.gwdg.de:/pub/linux/misc/ncpfs Alternate-site: sunsite.unc.edu:/pub/Linux/system/Filesystems/ncpfs - ~148k ncpfs-2.0.7.tgz - ~ 1k ncpfs-2.0.7.lsm + ~156k ncpfs-2.0.8.tgz + ~ 1k ncpfs-2.0.8.lsm Copying-policy: GPL End diff --git a/util/Makefile b/util/Makefile index 0a9e77b..1ef9936 100644 --- a/util/Makefile +++ b/util/Makefile @@ -6,6 +6,7 @@ USERUTILS = slist pqlist nwfsinfo pserver nprint nsend ncopy nwpasswd USERUTILS += nwbols nwbocreate nwborm nwboprops USERUTILS += nwbpcreate nwbprm nwbpvalues nwbpadd nwbpset USERUTILS += nwgrant nwrevoke nwuserlist nwrights nwauth +USERUTILS += nwfstime SBINUTILS = nwmsg UTILS = $(USERUTILS) $(SBINUTILS) ncptest diff --git a/util/nwfstime.c b/util/nwfstime.c new file mode 100644 index 0000000..1989ce0 --- /dev/null +++ b/util/nwfstime.c @@ -0,0 +1,98 @@ +/* + * nwfstime.c + * + * get/set a file server's time + * + * Copyright (C) 1996 by Volker Lendecke + * + */ + +#include +#include +#include "ncplib.h" + +static char *progname; + +static void +usage(void) +{ + fprintf(stderr, "usage: %s [pattern]\n", progname); +} + +static void +help(void) +{ + printf("\n"); + printf("usage: %s [options]\n", progname); + printf("\n" + "-h Print this help text\n" + "-S server Server name to be used\n" + "-U username Username sent to server\n" + "-P password Use this password\n" + "-n Do not use any password\n" + "-C Don't convert password to uppercase\n" + "\n" + "-s Set file server's time from local time\n" + "\n"); +} + +int +main(int argc, char **argv) +{ + struct ncp_conn *conn; + int opt; + long err; + int set = 0; + time_t t; + + progname = argv[0]; + + if ((conn = ncp_initialize(&argc, argv, 1, &err)) == NULL) + { + com_err(argv[0], err, "when initializing"); + return 1; + } + + while ((opt = getopt(argc, argv, "h?s")) != EOF) + { + switch(opt) + { + case 'h': + case '?': + help(); + break; + case 's': + set = 1; + break; + default: + usage(); + goto finished; + } + } + +finished: + + if (set != 0) + { + time(&t); + if ((err = ncp_set_file_server_time(conn, &t)) != 0) + { + com_err(argv[0], err, "when setting file server time"); + ncp_close(conn); + return 1; + } + } + else + { + if ((err = ncp_get_file_server_time(conn, &t)) != 0) + { + com_err(argv[0], err, "when getting file server time"); + ncp_close(conn); + return 1; + } + fputs(ctime(&t), stdout); + } + + ncp_close(conn); + return 0; +}