-/* $OpenBSD: child.c,v 1.24 2015/01/20 03:55:18 guenther Exp $ */
+/* $OpenBSD: child.c,v 1.25 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* SUCH DAMAGE.
*/
-#include "defs.h"
-
/*
* Functions for rdist related to children
*/
#include <sys/select.h>
#include <sys/wait.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "client.h"
+
typedef enum _PROCSTATE {
PSrunning,
PSdead
static CHILD *childlist = NULL; /* List of children */
int activechildren = 0; /* Number of active children */
-extern int maxchildren; /* Max active children */
static int needscan = FALSE; /* Need to scan children */
static void removechild(CHILD *);
-/* $OpenBSD: client.c,v 1.32 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: client.c,v 1.33 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* SUCH DAMAGE.
*/
+#include <ctype.h>
#include <dirent.h>
-
-#include "defs.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "client.h"
#include "y.tab.h"
/*
char *
remfilename(char *src, char *dest, char *path, char *rname, int destdir)
{
- extern struct namelist *filelist;
char *lname, *cp;
static char buff[BUFSIZ];
int srclen, pathlen;
runspecial(char *starget, opt_t opts, char *rname, int destdir)
{
struct subcmd *sc;
- extern struct subcmd *subcmds;
char *rfile;
rfile = remfilename(source, Tdest, target, rname, destdir);
char *rfile;
struct namelist *new;
struct subcmd *sc;
- extern struct subcmd *subcmds;
int isokay = 0;
rfile = remfilename(source, Tdest, target, rname, destdir);
--- /dev/null
+/* $OpenBSD: client.h,v 1.1 2015/01/20 09:00:16 guenther Exp $ */
+
+#ifndef __CLIENT_H__
+#define __CLIENT_H__
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * 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. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ */
+
+/*
+ * $From: defs.h,v 1.6 2001/03/12 18:16:30 kim Exp $
+ * @(#)defs.h 5.2 (Berkeley) 3/20/86
+ */
+
+#include <sys/stat.h>
+#include <regex.h>
+#include <stdio.h>
+
+#include "defs.h"
+
+ /* lexical definitions */
+#define QUOTECHAR 160 /* quote next character */
+
+ /* table sizes */
+#define HASHSIZE 1021
+#define INMAX 3500
+
+ /* expand type definitions */
+#define E_VARS 0x1
+#define E_SHELL 0x2
+#define E_TILDE 0x4
+#define E_ALL 0x7
+
+ /* actions for lookup() */
+#define LOOKUP 0
+#define INSERT 1
+#define REPLACE 2
+
+#define ALLOC(x) (struct x *) xmalloc(sizeof(struct x))
+#define A(s) ((s) ? s : "<null>")
+
+
+#define COMMENT_CHAR '#' /* Config file comment char */
+
+
+/*
+ * Name list
+ */
+struct namelist { /* for making lists of strings */
+ char *n_name;
+ regex_t *n_regex;
+ struct namelist *n_next;
+};
+
+/*
+ * Sub command structure
+ */
+struct subcmd {
+ short sc_type; /* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */
+ opt_t sc_options;
+ char *sc_name;
+ struct namelist *sc_args;
+ struct subcmd *sc_next;
+};
+
+/*
+ * Cmd flags
+ */
+#define CMD_ASSIGNED 0x01 /* This entry has been assigned */
+#define CMD_CONNFAILED 0x02 /* Connection failed */
+#define CMD_NOCHKNFS 0x04 /* Disable NFS checks */
+
+/*
+ * General command structure
+ */
+struct cmd {
+ int c_type; /* type - ARROW,DCOLON */
+ int c_flags; /* flags - CMD_USED,CMD_FAILED */
+ char *c_name; /* hostname or time stamp file name */
+ char *c_label; /* label for partial update */
+ struct namelist *c_files;
+ struct subcmd *c_cmds;
+ struct cmd *c_next;
+};
+
+/*
+ * Hard link buffer information
+ */
+struct linkbuf {
+ ino_t inum;
+ dev_t devnum;
+ int count;
+ char *pathname;
+ char *src;
+ char *target;
+ struct linkbuf *nextp;
+};
+
+extern char *path_remsh; /* Remote shell command */
+extern char host[]; /* Host name of master copy */
+extern char **realargv; /* Real argv */
+extern char *homedir; /* User's $HOME */
+extern int do_fork; /* Should we do fork()'ing */
+extern int nflag; /* NOP flag, don't execute commands */
+extern int realargc; /* Real argc */
+extern int setjmp_ok; /* setjmp/longjmp flag */
+extern int maxchildren; /* Max active children */
+extern int64_t min_freespace; /* Min filesys free space */
+extern int64_t min_freefiles; /* Min filesys free # files */
+extern struct linkbuf *ihead; /* list of files with more than one link */
+extern struct subcmd *subcmds;/* list of sub-commands for current cmd */
+extern struct namelist *filelist; /* list of source files */
+extern struct cmd *cmds; /* Initialized by yyparse() */
+
+extern char target[BUFSIZ]; /* target/source directory name */
+extern char *ptarget; /* pointer to end of target name */
+extern int activechildren; /* Number of active children */
+extern int amchild; /* This PID is a child */
+extern char *path_rdistd;
+extern char *remotemsglist;
+
+/*
+ * Our own declarations.
+ */
+
+/* child.c */
+void waitup(void);
+int spawn(struct cmd *, struct cmd *);
+
+/* client.c */
+char *remfilename(char *, char *, char *, char *, int);
+int inlist(struct namelist *, char *);
+void runcmdspecial(struct cmd *, opt_t);
+int checkfilename(char *);
+void freelinkinfo(struct linkbuf *);
+int install(char *, char *, int, int , opt_t);
+
+/* distopt.c */
+int parsedistopts(char *, opt_t *, int);
+char *getdistoptlist(void);
+char *getondistoptlist(opt_t);
+
+/* docmd.c */
+void markassigned(struct cmd *, struct cmd *);
+int okname(char *);
+int except(char *);
+void docmds(struct namelist *, int, char **);
+
+/* expand.c */
+struct namelist *expand(struct namelist *, int);
+u_char *xstrchr(u_char *, int);
+void expstr(u_char *);
+void expsh(u_char *);
+void matchdir(char *);
+int execbrc(u_char *, u_char *);
+int match(char *, char *);
+int amatch(char *, u_char *);
+
+/* gram.c */
+int yylex(void);
+int any(int, char *);
+void insert(char *, struct namelist *, struct namelist *, struct subcmd *);
+void append(char *, struct namelist *, char *, struct subcmd *);
+void yyerror(char *);
+struct namelist *makenl(char *);
+struct subcmd *makesubcmd(int);
+int yyparse(void);
+
+/* isexec.c */
+int isexec(char *, struct stat *);
+
+/* lookup.c */
+void define(char *);
+struct namelist *lookup(char *, int, struct namelist *);
+
+/* rdist.c */
+FILE *opendist(char *);
+void docmdargs(int, char *[]);
+char *getnlstr(struct namelist *);
+
+#endif /* __CLIENT_H__ */
-/* $OpenBSD: common.c,v 1.35 2015/01/20 04:45:43 guenther Exp $ */
+/* $OpenBSD: common.c,v 1.36 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* SUCH DAMAGE.
*/
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <limits.h>
+#include <paths.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
#include "defs.h"
/*
* Things common to both the client and server.
*/
-#include <sys/wait.h>
-#include <sys/socket.h>
-
/*
* Variables common to both client and server
*/
int rem_w = -1; /* Client file descriptor */
struct passwd *pw = NULL; /* Local user's pwd entry */
volatile sig_atomic_t contimedout = FALSE; /* Connection timed out */
-int proto_version = -1; /* Protocol version */
int rtimeout = RTIMEOUT; /* Response time out */
jmp_buf finish_jmpbuf; /* Finish() jmp buffer */
int setjmp_ok = FALSE; /* setjmp()/longjmp() status */
void
finish(void)
{
- extern jmp_buf finish_jmpbuf;
-
debugmsg(DM_CALL,
"finish() called: do_fork = %d amchild = %d isserver = %d",
do_fork, amchild, isserver);
{
char *pw_dir, *rest;
size_t len;
- extern char *homedir;
if (*file != '~') {
notilde:
-/* $OpenBSD: defs.h,v 1.34 2015/01/20 06:02:30 guenther Exp $ */
+/* $OpenBSD: defs.h,v 1.35 2015/01/20 09:00:16 guenther Exp $ */
#ifndef __DEFS_H__
#define __DEFS_H__
* @(#)defs.h 5.2 (Berkeley) 3/20/86
*/
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <errno.h>
-#include <grp.h>
#include <pwd.h>
-#include <paths.h>
-#include <regex.h>
#include <setjmp.h>
#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
#ifndef __GNUC__
# ifndef __attribute__
#include "config.h"
#include "pathnames.h"
#include "types.h"
-#include "filesys.h"
/*
* Define the read and write values for the file descriptor array
#define FALSE 0
#endif
- /* lexical definitions */
-#define QUOTECHAR 160 /* quote next character */
-
- /* table sizes */
-#define HASHSIZE 1021
-#define INMAX 3500
-
- /* expand type definitions */
-#define E_VARS 0x1
-#define E_SHELL 0x2
-#define E_TILDE 0x4
-#define E_ALL 0x7
-
- /* actions for lookup() */
-#define LOOKUP 0
-#define INSERT 1
-#define REPLACE 2
-
/* Bit flag test macros */
#define IS_ON(b,f) (b > 0 && (b & f))
#define IS_OFF(b,f) !(IS_ON(b,f))
#define FLAG_ON(b,f) b |= f
#define FLAG_OFF(b,f) b &= ~(f)
-#define ALLOC(x) (struct x *) xmalloc(sizeof(struct x))
-#define A(s) ((s) ? s : "<null>")
-
/*
* Environment variable names
*/
#define E_REMFILE "REMFILE" /* Remote Filename */
#define E_BASEFILE "BASEFILE" /* basename of Remote File */
-/*
- * Suffix to use when saving files
- */
-#ifndef SAVE_SUFFIX
-#define SAVE_SUFFIX ".OLD"
-#endif
-
/*
* Get system error string
*/
-#define SYSERR strerror(errno)
+#define SYSERR strerror(errno)
-#define COMMENT_CHAR '#' /* Config file comment char */
#define CNULL '\0' /* NULL character */
/*
#define C_CMDSPECIAL 's' /* Execute cmd special command */
#define C_CHMOG 'M' /* Chown,Chgrp,Chmod a file */
-#define ack() (void) sendcmd(C_ACK, NULL)
-#define err() (void) sendcmd(C_ERRMSG, NULL)
+#define ack() (void) sendcmd(C_ACK, NULL)
+#define err() (void) sendcmd(C_ERRMSG, NULL)
/*
* Session startup commands.
#define RC_FILE 'F' /* Name of a target file */
#define RC_COMMAND 'C' /* Command to run */
-/*
- * Name list
- */
-struct namelist { /* for making lists of strings */
- char *n_name;
- regex_t *n_regex;
- struct namelist *n_next;
-};
-
-/*
- * Sub command structure
- */
-struct subcmd {
- short sc_type; /* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */
- opt_t sc_options;
- char *sc_name;
- struct namelist *sc_args;
- struct subcmd *sc_next;
-};
-
-/*
- * Cmd flags
- */
-#define CMD_ASSIGNED 0x01 /* This entry has been assigned */
-#define CMD_CONNFAILED 0x02 /* Connection failed */
-#define CMD_NOCHKNFS 0x04 /* Disable NFS checks */
-
-/*
- * General command structure
- */
-struct cmd {
- int c_type; /* type - ARROW,DCOLON */
- int c_flags; /* flags - CMD_USED,CMD_FAILED */
- char *c_name; /* hostname or time stamp file name */
- char *c_label; /* label for partial update */
- struct namelist *c_files;
- struct subcmd *c_cmds;
- struct cmd *c_next;
-};
-
-/*
- * Hard link buffer information
- */
-struct linkbuf {
- ino_t inum;
- dev_t devnum;
- int count;
- char *pathname;
- char *src;
- char *target;
- struct linkbuf *nextp;
-};
-extern char *optarg; /* Option argument */
-extern char *path_remsh; /* Remote shell command */
-extern char host[]; /* Host name of master copy */
-extern char *currenthost; /* Name of current host */
-extern char *progname; /* Name of this program */
-extern char **realargv; /* Real argv */
-extern int optind; /* Option index into argv */
-extern int debug; /* Debugging flag */
-extern opt_t defoptions; /* Default install options */
-extern int do_fork; /* Should we do fork()'ing */
-extern int isserver; /* Acting as remote server */
-extern int nerrs; /* Number of errors seen */
-extern int nflag; /* NOP flag, don't execute commands */
-extern opt_t options; /* Global options */
-extern int proto_version; /* Protocol version number */
-extern int realargc; /* Real argc */
+extern char *currenthost; /* Name of current host */
+extern char *progname; /* Name of this program */
+extern char *locuser; /* Local User's name */
+extern int debug; /* Debugging flag */
+extern int isserver; /* Acting as remote server */
+extern int nerrs; /* Number of errors seen */
+extern opt_t options; /* Global options */
extern int rem_r; /* Remote file descriptor, reading */
-extern int rem_w; /* Remote file descriptor, writing */
-extern int rtimeout; /* Response time out in seconds */
-extern int setjmp_ok; /* setjmp/longjmp flag */
-extern uid_t userid; /* User ID of rdist user */
-extern jmp_buf finish_jmpbuf; /* Setjmp buffer for finish() */
-extern struct linkbuf *ihead; /* list of files with more than one link */
+extern int rem_w; /* Remote file descriptor, writing */
+extern int rtimeout; /* Response time out in seconds */
+extern uid_t userid; /* User ID of rdist user */
+extern jmp_buf finish_jmpbuf; /* Setjmp buffer for finish() */
extern struct passwd *pw; /* pointer to static area used by getpwent */
extern char defowner[64]; /* Default owner */
extern char defgroup[64]; /* Default group */
extern volatile sig_atomic_t contimedout; /* Connection timed out */
+
/*
- * Our own declarations.
+ * Declarations for files shared between rdist and rdistd
*/
-/* child.c */
-void waitup(void);
-int spawn(struct cmd *, struct cmd *);
-
-/* client.c */
-char *remfilename(char *, char *, char *, char *, int);
-int inlist(struct namelist *, char *);
-void runcmdspecial(struct cmd *, opt_t);
-int checkfilename(char *);
-void freelinkinfo(struct linkbuf *);
-void cleanup(int);
-int install(char *, char *, int, int , opt_t);
-
/* common.c */
ssize_t xwrite(int, void *, size_t);
int init(int, char **, char **);
char *xbasename(char *);
char *searchpath(char *);
-/* distopt.c */
-int parsedistopts(char *, opt_t *, int);
-char *getdistoptlist(void);
-char *getondistoptlist(opt_t);
-
-/* docmd.c */
-void markassigned(struct cmd *, struct cmd *);
-int okname(char *);
-int except(char *);
-void docmds(struct namelist *, int, char **);
-
-/* expand.c */
-struct namelist *expand(struct namelist *, int);
-u_char *xstrchr(u_char *, int);
-void expstr(u_char *);
-void expsh(u_char *);
-void matchdir(char *);
-int execbrc(u_char *, u_char *);
-int match(char *, char *);
-int amatch(char *, u_char *);
-
-/* filesys.c */
-char *find_file(char *, struct stat *, int *);
-mntent_t *findmnt(struct stat *, struct mntinfo *);
-int isdupmnt(mntent_t *, struct mntinfo *);
-void wakeup(int);
-struct mntinfo *makemntinfo(struct mntinfo *);
-mntent_t *getmntpt(char *, struct stat *, int *);
-int is_nfs_mounted(char *, struct stat *, int *);
-int is_ro_mounted(char *, struct stat *, int *);
-int is_symlinked(char *, struct stat *, int *);
-int getfilesysinfo(char *, int64_t *, int64_t *);
-
-/* gram.c */
-int yylex(void);
-int any(int, char *);
-void insert(char *, struct namelist *, struct namelist *, struct subcmd *);
-void append(char *, struct namelist *, char *, struct subcmd *);
-void yyerror(char *);
-struct namelist *makenl(char *);
-struct subcmd *makesubcmd(int);
-int yyparse(void);
-
-/* isexec.c */
-int isexec(char *, struct stat *);
-
-/* lookup.c */
-void define(char *);
-struct namelist *lookup(char *, int, struct namelist *);
-
/* message.c */
void msgprusage(void);
void msgprconfig(void);
void fatalerr(const char *, ...) __attribute__((format (printf, 1, 2)));
char *getnotifyfile(void);
-/* rdist.c */
-FILE *opendist(char *);
-void docmdargs(int, char *[]);
-char *getnlstr(struct namelist *);
-
-/* server.c */
-void server(void);
+/* client.c or server.c */
+void cleanup(int);
#include <vis.h>
#define DECODE(a, b) strunvis(a, b)
-/* $OpenBSD: distopt.c,v 1.12 2015/01/20 06:02:30 guenther Exp $ */
+/* $OpenBSD: distopt.c,v 1.13 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* SUCH DAMAGE.
*/
-#include "defs.h"
+#include <stdlib.h>
+#include <string.h>
+
+#include "client.h"
/*
* Dist Option functions
-/* $OpenBSD: docmd.c,v 1.31 2014/07/12 03:48:04 guenther Exp $ */
+/* $OpenBSD: docmd.c,v 1.32 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* SUCH DAMAGE.
*/
-#include <sys/socket.h>
+#include <ctype.h>
#include <dirent.h>
-#include <netdb.h>
-
-#include "defs.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "client.h"
#include "y.tab.h"
/*
struct subcmd *subcmds; /* list of sub-commands for
current cmd */
struct namelist *filelist; /* list of source files */
-extern struct cmd *cmds; /* Initialized by yyparse() */
time_t lastmod; /* Last modify time */
-extern char target[BUFSIZ];
-extern char *ptarget;
-extern int activechildren;
-extern int maxchildren;
-extern int amchild;
-extern char *path_rdistd;
-
static void closeconn(void);
static void notify(char *, struct namelist *, time_t);
static void checkcmd(struct cmd *);
FILE *pf;
struct stat stb;
static char buf[BUFSIZ];
- extern char *locuser;
char *file, *user;
if (IS_ON(options, DO_VERIFY) || to == NULL)
{
char *ruser, *cp;
static char *cur_host = NULL;
- extern char *locuser;
- extern int64_t min_freefiles, min_freespace;
- extern char *remotemsglist;
char tuser[BUFSIZ], buf[BUFSIZ];
u_char respbuff[BUFSIZ];
int n;
/*
* The server sent it's version number to us
*/
- proto_version = atoi(&respbuff[1]);
+ int proto_version = atoi(&respbuff[1]);
if (proto_version != VERSION) {
fatalerr(
"Server version (%d) is not the same as local version (%d).",
-/* $OpenBSD: expand.c,v 1.14 2014/07/05 06:45:00 guenther Exp $ */
+/* $OpenBSD: expand.c,v 1.15 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
*/
#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
-#include "defs.h"
+#include "client.h"
#define MAXEARGS 2048
#define LC '{'
u_char ebuf[BUFSIZ];
u_char varbuff[BUFSIZ];
int savec, oeargc;
- extern char *homedir;
if (s == NULL || *s == CNULL)
return;
+++ /dev/null
-/* $OpenBSD: filesys.h,v 1.4 2014/07/05 10:21:24 guenther Exp $ */
-
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * 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. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-
-/*
- * $From: filesys.h,v 1.2 1999/08/04 15:57:31 christos Exp $
- * @(#)filesys.h
- */
-
-#ifndef __filesys_h__
-#define __filesys_h__
-
-/*
- * File System information
- */
-
-/*
- * Mount Entry definetions
- */
-#ifndef METYPE_OTHER
-#define METYPE_OTHER "other"
-#endif
-#ifndef METYPE_NFS
-#define METYPE_NFS "nfs"
-#endif
-#ifndef MEFLAG_READONLY
-#define MEFLAG_READONLY 0x01
-#endif
-#ifndef MEFLAG_IGNORE
-#define MEFLAG_IGNORE 0x02
-#endif
-
-/*
- * Our internal mount entry type
- */
-struct _mntent {
- char *me_path; /* Mounted path */
- char *me_type; /* Type of mount */
- int me_flags; /* Mount flags */
-};
-typedef struct _mntent mntent_t;
-
-/*
- * Internal mount information type
- */
-struct mntinfo {
- mntent_t *mi_mnt;
- struct stat *mi_statb;
- struct mntinfo *mi_nxt;
-};
-
-/*
- * Declarations
- */
-int setmountent(void);
-mntent_t *getmountent(void);
-mntent_t *newmountent(const mntent_t *);
-void endmountent(void);
-
-#endif /* __filesys_h__ */
%{
-/* $OpenBSD: gram.y,v 1.11 2014/06/07 15:28:21 deraadt Exp $ */
+/* $OpenBSD: gram.y,v 1.12 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1993 Michael A. Cooper
* SUCH DAMAGE.
*/
-#include "defs.h"
+#include "client.h"
static struct namelist *addnl(struct namelist *, struct namelist *);
static struct namelist *subnl(struct namelist *, struct namelist *);
*/
void
insert(char *label, struct namelist *files, struct namelist *hosts,
- struct subcmd *subcmds)
+ struct subcmd *scmds)
{
struct cmd *c, *prev, *nc;
struct namelist *h, *lasth;
debugmsg(DM_CALL, "insert(%s, %p, %p, %p) start, files = %s",
label == NULL ? "(null)" : label,
- files, hosts, subcmds, getnlstr(files));
+ files, hosts, scmds, getnlstr(files));
files = expand(files, E_VARS|E_SHELL);
hosts = expand(hosts, E_ALL);
nc->c_name = h->n_name;
nc->c_label = label;
nc->c_files = files;
- nc->c_cmds = subcmds;
+ nc->c_cmds = scmds;
nc->c_flags = 0;
nc->c_next = c;
if (prev == NULL)
* executed in the order they appear in the distfile.
*/
void
-append(char *label, struct namelist *files, char *stamp, struct subcmd *subcmds)
+append(char *label, struct namelist *files, char *stamp, struct subcmd *scmds)
{
struct cmd *c;
c->c_name = stamp;
c->c_label = label;
c->c_files = expand(files, E_ALL);
- c->c_cmds = subcmds;
+ c->c_cmds = scmds;
c->c_next = NULL;
if (cmds == NULL)
cmds = last_cmd = c;
-/* $OpenBSD: isexec.c,v 1.9 2014/07/05 05:31:35 guenther Exp $ */
+/* $OpenBSD: isexec.c,v 1.10 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* SUCH DAMAGE.
*/
-#include "defs.h"
-
+#include <sys/types.h>
#include <elf_abi.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "client.h"
/*
* Determine whether 'file' is a binary executable or not.
-/* $OpenBSD: lookup.c,v 1.14 2012/11/12 01:14:41 guenther Exp $ */
+/* $OpenBSD: lookup.c,v 1.15 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* SUCH DAMAGE.
*/
-#include "defs.h"
+#include <string.h>
+
+#include "client.h"
/* symbol types */
#define VAR 1
-/* $OpenBSD: message.c,v 1.26 2015/01/20 07:03:21 guenther Exp $ */
+/* $OpenBSD: message.c,v 1.27 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* SUCH DAMAGE.
*/
+#include <errno.h>
+#include <limits.h>
+#include <paths.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <syslog.h>
+#include <unistd.h>
+
#include "defs.h"
/*
-/* $OpenBSD: rdist.c,v 1.28 2014/07/12 03:32:00 guenther Exp $ */
+/* $OpenBSD: rdist.c,v 1.29 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* SUCH DAMAGE.
*/
-#include "defs.h"
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <paths.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "client.h"
#include "y.tab.h"
-#include <netdb.h>
-#include <sys/ioctl.h>
/*
* Remote distribution program.
struct namelist *nl, *prev;
char *cp;
struct namelist *files, *hosts;
- struct subcmd *cmds;
+ struct subcmd *scmds;
char *dest;
static struct namelist tnl;
int i;
exit(1);
if (dest == NULL || *dest == '\0')
- cmds = NULL;
+ scmds = NULL;
else {
- cmds = makesubcmd(INSTALL);
- cmds->sc_options = options;
- cmds->sc_name = dest;
+ scmds = makesubcmd(INSTALL);
+ scmds->sc_options = options;
+ scmds->sc_name = dest;
}
debugmsg(DM_MISC, "docmdargs()\nfiles = %s", getnlstr(files));
debugmsg(DM_MISC, "host = %s", getnlstr(hosts));
- insert(NULL, files, hosts, cmds);
+ insert(NULL, files, hosts, scmds);
docmds(NULL, 0, NULL);
}
-/* $OpenBSD: filesys-os.c,v 1.12 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: filesys-os.c,v 1.13 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
#include <sys/types.h>
#include <sys/mount.h>
+#include <stdlib.h>
+#include <string.h>
-#include "defs.h"
+#include "server.h"
/*
* OS specific file system routines
if (strcmp(mnt->f_fstypename, "nfs") == 0) {
strlcpy(remote_dev, mnt->f_mntfromname, sizeof(remote_dev));
mntstruct.me_path = remote_dev;
- mntstruct.me_type = METYPE_NFS;
- } else {
+ mntstruct.me_flags |= MEFLAG_NFS;
+ } else
mntstruct.me_path = mnt->f_mntonname;
- mntstruct.me_type = METYPE_OTHER;
- }
mnt++;
entries_left--;
new = xmalloc(sizeof *new);
new->me_path = xstrdup(old->me_path);
- new->me_type = xstrdup(old->me_type);
new->me_flags = old->me_flags;
return (new);
-/* $OpenBSD: filesys.c,v 1.17 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: filesys.c,v 1.18 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
#include <sys/types.h>
#include <sys/mount.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
-#include "defs.h"
+#include "server.h"
/*
* This file contains functions dealing with getting info
mntinfo = mi;
while ((mnt = getmountent()) != NULL) {
- debugmsg(DM_MISC, "mountent = '%s' (%s)",
- mnt->me_path, mnt->me_type);
+ debugmsg(DM_MISC, "mountent = '%s'", mnt->me_path);
/*
* Make sure we don't already have it for some reason
{
mntent_t *mnt;
- if ((mnt = (mntent_t *) getmntpt(path, statbuf, isvalid)) == NULL)
+ if ((mnt = getmntpt(path, statbuf, isvalid)) == NULL)
return(-1);
- /*
- * We treat "cachefs" just like NFS
- */
- if ((strcmp(mnt->me_type, METYPE_NFS) == 0) ||
- (strcmp(mnt->me_type, "cachefs") == 0))
+ if (mnt->me_flags & MEFLAG_NFS)
return(1);
return(0);
-/* $OpenBSD: rdistd.c,v 1.8 2009/10/27 23:59:42 deraadt Exp $ */
+/* $OpenBSD: rdistd.c,v 1.9 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* SUCH DAMAGE.
*/
-#include "defs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "server.h"
int main(int, char **, char **);
static void usage(void);
-/* $OpenBSD: server.c,v 1.34 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: server.c,v 1.35 2015/01/20 09:00:16 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* SUCH DAMAGE.
*/
+#include <ctype.h>
#include <dirent.h>
-
-#include "defs.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "server.h"
/*
* Server routines
fchog(int fd, char *file, char *owner, char *group, int mode)
{
static struct group *gr = NULL;
- extern char *locuser;
int i;
struct stat st;
uid_t uid;
{
static char cmdbuf[BUFSIZ];
char *cp;
- int n;
- extern jmp_buf finish_jmpbuf;
+ int n, proto_version;
if (setjmp(finish_jmpbuf))
return;
--- /dev/null
+/* $OpenBSD: server.h,v 1.1 2015/01/20 09:00:16 guenther Exp $ */
+
+#ifndef __SERVER_H__
+#define __SERVER_H__
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * 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. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ */
+
+/*
+ * $From: defs.h,v 1.6 2001/03/12 18:16:30 kim Exp $
+ * @(#)defs.h 5.2 (Berkeley) 3/20/86
+ */
+
+#include <sys/stat.h>
+
+#include "defs.h"
+
+/*
+ * Suffix to use when saving files
+ */
+#ifndef SAVE_SUFFIX
+#define SAVE_SUFFIX ".OLD"
+#endif
+
+
+#define MEFLAG_READONLY 0x01
+#define MEFLAG_IGNORE 0x02
+#define MEFLAG_NFS 0x04
+
+/*
+ * Our internal mount entry type
+ */
+typedef struct {
+ char *me_path; /* Mounted path */
+ int me_flags; /* Mount flags */
+} mntent_t;
+
+/*
+ * Internal mount information type
+ */
+struct mntinfo {
+ mntent_t *mi_mnt;
+ struct stat *mi_statb;
+ struct mntinfo *mi_nxt;
+};
+
+/* filesys-os.c */
+int setmountent(void);
+mntent_t *getmountent(void);
+mntent_t *newmountent(const mntent_t *);
+void endmountent(void);
+
+/* filesys.c */
+char *find_file(char *, struct stat *, int *);
+mntent_t *findmnt(struct stat *, struct mntinfo *);
+int isdupmnt(mntent_t *, struct mntinfo *);
+void wakeup(int);
+struct mntinfo *makemntinfo(struct mntinfo *);
+mntent_t *getmntpt(char *, struct stat *, int *);
+int is_nfs_mounted(char *, struct stat *, int *);
+int is_ro_mounted(char *, struct stat *, int *);
+int is_symlinked(char *, struct stat *, int *);
+int getfilesysinfo(char *, int64_t *, int64_t *);
+
+/* server.c */
+void server(void);
+
+#endif /* __SERVER_H__ */