cleanups, add manual page
[unix-history] / usr / src / usr.bin / rdist / server.c
index 8bc3d90..92fe19a 100644 (file)
@@ -1,12 +1,23 @@
 /*
  * Copyright (c) 1983 Regents of the University of California.
 /*
  * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)server.c   5.2 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)server.c   5.8 (Berkeley) %G%";
+#endif /* not lint */
 
 #include "defs.h"
 
 
 #include "defs.h"
 
@@ -283,13 +294,15 @@ sendf(rname, opts)
 
        if (pw == NULL || pw->pw_uid != stb.st_uid)
                if ((pw = getpwuid(stb.st_uid)) == NULL) {
 
        if (pw == NULL || pw->pw_uid != stb.st_uid)
                if ((pw = getpwuid(stb.st_uid)) == NULL) {
-                       log(lfp, "%s: no password entry for uid \n", target);
+                       log(lfp, "%s: no password entry for uid %d \n",
+                               target, stb.st_uid);
                        pw = NULL;
                        sprintf(user, ":%d", stb.st_uid);
                }
        if (gr == NULL || gr->gr_gid != stb.st_gid)
                if ((gr = getgrgid(stb.st_gid)) == NULL) {
                        pw = NULL;
                        sprintf(user, ":%d", stb.st_uid);
                }
        if (gr == NULL || gr->gr_gid != stb.st_gid)
                if ((gr = getgrgid(stb.st_gid)) == NULL) {
-                       log(lfp, "%s: no name for group %d\n", target);
+                       log(lfp, "%s: no name for group %d\n",
+                               target, stb.st_gid);
                        gr = NULL;
                        sprintf(group, ":%d", stb.st_gid);
                }
                        gr = NULL;
                        sprintf(group, ":%d", stb.st_gid);
                }
@@ -379,7 +392,7 @@ sendf(rname, opts)
                sizerr = (readlink(target, buf, BUFSIZ) != stb.st_size);
                (void) write(rem, buf, stb.st_size);
                if (debug)
                sizerr = (readlink(target, buf, BUFSIZ) != stb.st_size);
                (void) write(rem, buf, stb.st_size);
                if (debug)
-                       printf("readlink = %.*s\n", stb.st_size, buf);
+                       printf("readlink = %.*s\n", (int)stb.st_size, buf);
                goto done;
 
        case S_IFREG:
                goto done;
 
        case S_IFREG:
@@ -722,8 +735,8 @@ recvf(cmd, type)
                                }
                                buf[0] = '\0';
                                (void) sprintf(buf + 1,
                                }
                                buf[0] = '\0';
                                (void) sprintf(buf + 1,
-                                       "%s:%s: Warning: remote mode %o != local mode %o\n",
-                                       host, target, stb.st_mode & 07777, mode);
+                                       "%s: Warning: remote mode %o != local mode %o\n",
+                                       target, stb.st_mode & 07777, mode);
                                (void) write(rem, buf, strlen(buf + 1) + 1);
                                return;
                        }
                                (void) write(rem, buf, strlen(buf + 1) + 1);
                                return;
                        }
@@ -888,7 +901,7 @@ badt:
        }
        if (opts & COMPARE) {
                buf[0] = '\0';
        }
        if (opts & COMPARE) {
                buf[0] = '\0';
-               (void) sprintf(buf + 1, "%s: updated %s\n", host, target);
+               (void) sprintf(buf + 1, "updated %s\n", target);
                (void) write(rem, buf, strlen(buf + 1) + 1);
        } else
                ack();
                (void) write(rem, buf, strlen(buf + 1) + 1);
        } else
                ack();
@@ -1035,7 +1048,7 @@ ok:
        if (userid)
                setreuid(userid, 0);
        if (chown(file, uid, gid) < 0 ||
        if (userid)
                setreuid(userid, 0);
        if (chown(file, uid, gid) < 0 ||
-           (mode & 06000) && chmod(file, mode) < 0) {
+           (mode & 07000) && chmod(file, mode) < 0) {
                note("%s: chown or chmod failed: file %s:  %s",
                             host, file, sys_errlist[errno]);
        }
                note("%s: chown or chmod failed: file %s:  %s",
                             host, file, sys_errlist[errno]);
        }