From 6e74bb597407eff2208033ed73a4a82facf906d0 Mon Sep 17 00:00:00 2001 From: "Yury G. Kudryashov" Date: Mon, 28 Jan 2008 19:51:14 +0000 Subject: [PATCH] finger client and daemon added svn path=/nixpkgs/trunk/; revision=10364 --- pkgs/servers/fingerd/bsd-fingerd/default.nix | 17 ++ .../fingerd/bsd-fingerd/ubuntu-0.17-9.patch | 67 +++++ pkgs/tools/networking/bsd-finger/default.nix | 17 ++ .../networking/bsd-finger/ubuntu-0.17-9.patch | 261 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 8 + 5 files changed, 370 insertions(+) create mode 100644 pkgs/servers/fingerd/bsd-fingerd/default.nix create mode 100644 pkgs/servers/fingerd/bsd-fingerd/ubuntu-0.17-9.patch create mode 100644 pkgs/tools/networking/bsd-finger/default.nix create mode 100644 pkgs/tools/networking/bsd-finger/ubuntu-0.17-9.patch diff --git a/pkgs/servers/fingerd/bsd-fingerd/default.nix b/pkgs/servers/fingerd/bsd-fingerd/default.nix new file mode 100644 index 00000000000..eacf2371d36 --- /dev/null +++ b/pkgs/servers/fingerd/bsd-fingerd/default.nix @@ -0,0 +1,17 @@ +args: with args; +stdenv.mkDerivation rec { + name = "bsd-fingerd-0.17"; + + src = fetchurl { + url = "ftp://ftp.metalab.unc.edu/pub/linux/system/network/finger/bsd-finger-0.17.tar.gz"; + sha256 = "1yhkiv0in588il7f84k2xiy78g9lv12ll0y7047gazhiimk5v244"; + }; + + NIX_CFLAGS_COMPILE="-D_GNU_SOURCE"; + + patches = [./ubuntu-0.17-9.patch]; + + preBuild = "cd fingerd"; + + preInstall = '' ensureDir $out/man/man8 $out/sbin ''; +} diff --git a/pkgs/servers/fingerd/bsd-fingerd/ubuntu-0.17-9.patch b/pkgs/servers/fingerd/bsd-fingerd/ubuntu-0.17-9.patch new file mode 100644 index 00000000000..80968d587ba --- /dev/null +++ b/pkgs/servers/fingerd/bsd-fingerd/ubuntu-0.17-9.patch @@ -0,0 +1,67 @@ +--- bsd-finger-0.17.orig/fingerd/fingerd.8 ++++ bsd-finger-0.17/fingerd/fingerd.8 +@@ -36,10 +36,10 @@ + .Dt FINGERD 8 + .Os "Linux NetKit (0.17)" + .Sh NAME +-.Nm fingerd ++.Nm in.fingerd + .Nd remote user information server + .Sh SYNOPSIS +-.Nm fingerd ++.Nm in.fingerd + .Op Fl wulf + .Op Fl pL Ar path + .Op Fl t Ar timeout +@@ -61,7 +61,7 @@ + banner + which also shows some informations (e.g. uptime, operating system name and + release) about the system the +-.Nm fingerd ++.Nm in.fingerd + is running on. Some sites may consider this a security risk as it + gives out information that may be useful to crackers. + .Pp +@@ -85,7 +85,7 @@ + .Pp + The + .Fl p +-option allows specification of an alternate location for fingerd to find ++option allows specification of an alternate location for in.fingerd to find + the + .Dq finger + program. The +@@ -97,7 +97,7 @@ + option specifies the time to wait for a request before closing the + connection. A value of 0 waits forever. The default is 60 seconds. + .Pp +-Options to fingerd should be specified in ++Options to in.fingerd should be specified in + .Pa /etc/inetd.conf . + .Pp + The finger protocol consists mostly of specifying command arguments. +@@ -105,12 +105,12 @@ + .Xr inetd 8 + .Dq super-server + runs +-.Nm fingerd ++.Nm in.fingerd + for + .Tn TCP + requests received on port 79. + Once connected +-.Nm fingerd ++.Nm in.fingerd + reads a single command line + terminated by a + .Aq Tn CRLF +--- bsd-finger-0.17.orig/fingerd/fingerd.c ++++ bsd-finger-0.17/fingerd/fingerd.c +@@ -55,6 +55,7 @@ + #include + #include + #include ++#include + + #include "pathnames.h" + #include "../version.h" diff --git a/pkgs/tools/networking/bsd-finger/default.nix b/pkgs/tools/networking/bsd-finger/default.nix new file mode 100644 index 00000000000..d627235494b --- /dev/null +++ b/pkgs/tools/networking/bsd-finger/default.nix @@ -0,0 +1,17 @@ +args: with args; +stdenv.mkDerivation rec { + name = "bsd-finger-0.17"; + + src = fetchurl { + url = "ftp://ftp.metalab.unc.edu/pub/linux/system/network/finger/${name}.tar.gz"; + sha256 = "1yhkiv0in588il7f84k2xiy78g9lv12ll0y7047gazhiimk5v244"; + }; + + NIX_CFLAGS_COMPILE="-D_GNU_SOURCE"; + + patches = [./ubuntu-0.17-9.patch]; + + preBuild = "cd finger"; + + preInstall = '' ensureDir $out/man/man1 $out/bin ''; +} diff --git a/pkgs/tools/networking/bsd-finger/ubuntu-0.17-9.patch b/pkgs/tools/networking/bsd-finger/ubuntu-0.17-9.patch new file mode 100644 index 00000000000..24decb60281 --- /dev/null +++ b/pkgs/tools/networking/bsd-finger/ubuntu-0.17-9.patch @@ -0,0 +1,261 @@ +--- bsd-finger-0.17.orig/finger/finger.1 ++++ bsd-finger-0.17/finger/finger.1 +@@ -169,16 +169,14 @@ + must be able to see the + .Pa .nofinger + file. This generally means that the home directory containing the file +-must have the other-users-execute bit set (o+w). See ++must have the other-users-execute bit set (o+x). See + .Xr chmod 1 . + If you use this feature for privacy, please test it with ``finger + @localhost'' before relying on it, just in case. + .It ~/.plan + .It ~/.project +-.It ~/.pgp ++.It ~/.pgpkey + These files are printed as part of a long-format request. The +-.Pa .project +-file is limited to one line; the + .Pa .plan + file may be arbitrarily long. + .El +--- bsd-finger-0.17.orig/finger/finger.c ++++ bsd-finger-0.17/finger/finger.c +@@ -77,7 +77,7 @@ + #include "../version.h" + + static void loginlist(void); +-static void userlist(int argc, char *argv[]); ++static int userlist(int argc, char *argv[]); + + int lflag, pplan; + static int sflag, mflag; +@@ -92,6 +92,7 @@ + + int main(int argc, char *argv[]) { + int ch; ++ int err = 0; + struct sockaddr_in sin; + socklen_t slen = sizeof(sin); + +@@ -159,7 +160,7 @@ + } + } + else { +- userlist(argc, argv); ++ err = userlist(argc, argv); + /* + * Assign explicit "large" format if names given and -s not + * explicitly stated. Force the -l AFTER we get names so any +@@ -172,7 +173,7 @@ + if (lflag) lflag_print(); + else sflag_print(); + } +- return 0; ++ return err; + } + + /* Returns 1 if .nofinger is found and enable_nofinger is set. */ +@@ -181,10 +182,16 @@ + check_nofinger(struct passwd *pw) + { + if (enable_nofinger) { +- char path[PATH_MAX]; + struct stat tripe; +- snprintf(path, sizeof(path), "%s/.nofinger", pw->pw_dir); +- if (stat(path, &tripe)==0) { ++ int ret; ++ char *path; ++ if (asprintf(&path, "%s/.nofinger", pw->pw_dir) < 0) { ++ eprintf("finger: Out of space.\n"); ++ exit(1); ++ } ++ ret = stat(path, &tripe); ++ free(path); ++ if (!ret) { + return 1; + } + } +@@ -264,10 +271,11 @@ + + } + +-static void ++static int + userlist(int argc, char *argv[]) + { + int i; ++ int err = 0; + PERSON *pn; + PERSON *nethead, **nettail; + struct utmp *uptr; +@@ -297,13 +305,13 @@ + + /* handle network requests */ + for (pn = nethead; pn; pn = pn->next) { +- netfinger(pn->name); ++ err |= netfinger(pn->name); + if (pn->next || entries) + xputc('\n'); + } + + if (entries == 0) +- return; ++ return err; + + /* + * Scan thru the list of users currently logged in, saving +@@ -331,4 +339,6 @@ + enter_lastlog(pn); + } + endutent(); ++ ++ return err; + } +--- bsd-finger-0.17.orig/finger/finger.h ++++ bsd-finger-0.17/finger/finger.h +@@ -92,7 +92,7 @@ + void enter_where(struct utmp *ut, PERSON *pn); + void enter_lastlog(PERSON *pn); + int match(struct passwd *pw, const char *user); +-void netfinger(const char *name); ++int netfinger(const char *name); + const char *prphone(const char *num); + + #ifndef DAYSPERNYEAR +--- bsd-finger-0.17.orig/finger/lprint.c ++++ bsd-finger-0.17/finger/lprint.c +@@ -48,7 +48,7 @@ + #include + #include + #include +-#include ++#include + #include "finger.h" + + static void lprint(PERSON *pn); +@@ -100,7 +100,7 @@ + * office, office phone, home phone if available + */ + xprintf("Login: %-15s\t\t\tName: %s\nDirectory: %-25s", +- pn->name, pn->realname, pn->dir); ++ pn->name, pn->realname ? pn->realname : "", pn->dir); + xprintf("\tShell: %-s\n", *pn->shell ? pn->shell : _PATH_BSHELL); + + /* +--- bsd-finger-0.17.orig/finger/net.c ++++ bsd-finger-0.17/finger/net.c +@@ -51,7 +51,7 @@ + #include + #include "finger.h" + +-void netfinger(const char *name) { ++int netfinger(const char *name) { + register FILE *fp; + struct in_addr defaddr; + register int c, sawret, ateol; +@@ -62,7 +62,7 @@ + char *alist[1], *host; + + host = strrchr(name, '@'); +- if (!host) return; ++ if (!host) return 1; + *host++ = '\0'; + + memset(&sn, 0, sizeof(sn)); +@@ -70,7 +70,7 @@ + sp = getservbyname("finger", "tcp"); + if (!sp) { + eprintf("finger: tcp/finger: unknown service\n"); +- return; ++ return 1; + } + sn.sin_port = sp->s_port; + +@@ -78,7 +78,7 @@ + if (!hp) { + if (!inet_aton(host, &defaddr)) { + eprintf("finger: unknown host: %s\n", host); +- return; ++ return 1; + } + def.h_name = host; + def.h_addr_list = alist; +@@ -96,7 +96,7 @@ + + if ((s = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) { + eprintf("finger: socket: %s\n", strerror(errno)); +- return; ++ return 1; + } + + /* print hostname before connecting, in case it takes a while */ +@@ -104,7 +104,7 @@ + if (connect(s, (struct sockaddr *)&sn, sizeof(sn)) < 0) { + eprintf("finger: connect: %s\n", strerror(errno)); + close(s); +- return; ++ return 1; + } + + /* -l flag for remote fingerd */ +@@ -128,7 +128,7 @@ + if (!fp) { + eprintf("finger: fdopen: %s\n", strerror(errno)); + close(s); +- return; ++ return 1; + } + + sawret = 0; +@@ -152,4 +152,6 @@ + } + if (!ateol) xputc('\n'); + fclose(fp); ++ ++ return 0; + } +--- bsd-finger-0.17.orig/finger/sprint.c ++++ bsd-finger-0.17/finger/sprint.c +@@ -40,7 +40,7 @@ + #endif /* not lint */ + + #include +-#include ++#include + #include + #include + #include +--- bsd-finger-0.17.orig/finger/util.c ++++ bsd-finger-0.17/finger/util.c +@@ -64,7 +64,7 @@ + struct stat sb; + + /* No device for X console. Utmp entry by XDM login (":0"). */ +- if (w->tty[0] == ':') { ++ if (strchr(w->tty, ':')) { + w->idletime = 0; /* would be nice to have it emit ??? */ + w->writable = 0; + return; +@@ -109,9 +109,8 @@ + * fields[3] -> homephone + */ + nfields = 0; +- for (p = strtok(bp, ","); p; p = strtok(NULL, ",")) { +- if (*p==0) p = NULL; // skip empties +- if (nfields < 4) fields[nfields++] = p; ++ while ((p = strsep(&bp, ","))) { ++ if (nfields < 4) fields[nfields++] = *p ? p : NULL; + } + while (nfields<4) fields[nfields++] = NULL; + +@@ -150,6 +149,9 @@ + + pn->realname = rname; + } ++ else { ++ pn->realname = NULL; ++ } + + pn->office = fields[1] ? strdup(fields[1]) : NULL; + pn->officephone = fields[2] ? strdup(fields[2]) : NULL; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b19dc9ae4ec..3fa951bb626 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -452,6 +452,10 @@ rec { inherit stdenv findutils; })); + finger_bsd = import ../tools/networking/bsd-finger { + inherit fetchurl stdenv; + }; + fontforge = import ../tools/misc/fontforge { inherit fetchurl stdenv gettext freetype zlib libungif libpng libjpeg libtiff libxml2; @@ -3126,6 +3130,10 @@ rec { inherit fetchurl stdenv expat erlang zlib openssl; }; + fingerd_bsd = import ../servers/fingerd/bsd-fingerd { + inherit fetchurl stdenv; + }; + ircdHybrid = import ../servers/irc/ircd-hybrid { inherit fetchurl stdenv openssl zlib; };