ANSI C; sprintf now returns an int.
[unix-history] / usr / src / usr.bin / tip / cu.c
index 8784717..566ea3c 100644 (file)
@@ -1,6 +1,12 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)cu.c       4.6 (Berkeley) %G%";
-#endif
+static char sccsid[] = "@(#)cu.c       5.5 (Berkeley) %G%";
+#endif not lint
 
 #include "tip.h"
 
 
 #include "tip.h"
 
@@ -21,6 +27,7 @@ cumain(argc, argv)
                exit(8);
        }
        CU = DV = NOSTR;
                exit(8);
        }
        CU = DV = NOSTR;
+       BR = DEFBR;
        for (; argc > 1; argv++, argc--) {
                if (argv[1][0] != '-')
                        PN = argv[1];
        for (; argc > 1; argv++, argc--) {
                if (argv[1][0] != '-')
                        PN = argv[1];
@@ -36,7 +43,7 @@ cumain(argc, argv)
                        break;
 
                case 's':
                        break;
 
                case 's':
-                       if (speed(atoi(argv[2])) == 0) {
+                       if (argc < 3 || speed(atoi(argv[2])) == 0) {
                                fprintf(stderr, "cu: unsupported speed %s\n",
                                        argv[2]);
                                exit(3);
                                fprintf(stderr, "cu: unsupported speed %s\n",
                                        argv[2]);
                                exit(3);
@@ -70,7 +77,8 @@ cumain(argc, argv)
         * The "cu" host name is used to define the
         * attributes of the generic dialer.
         */
         * The "cu" host name is used to define the
         * attributes of the generic dialer.
         */
-       if ((i = hunt(sprintf(sbuf, "cu%d", BR))) == 0) {
+       (void)sprintf(sbuf, "cu%d", BR);
+       if ((i = hunt(sbuf)) == 0) {
                printf("all ports busy\n");
                exit(3);
        }
                printf("all ports busy\n");
                exit(3);
        }
@@ -81,8 +89,7 @@ cumain(argc, argv)
        }
        setbuf(stdout, NULL);
        loginit();
        }
        setbuf(stdout, NULL);
        loginit();
-       setuid(getuid());
-       setgid(getgid());
+       user_uid();
        vinit();
        setparity("none");
        boolean(value(VERBOSE)) = 0;
        vinit();
        setparity("none");
        boolean(value(VERBOSE)) = 0;
@@ -90,6 +97,7 @@ cumain(argc, argv)
                ttysetup(speed(BR));
        if (connect()) {
                printf("Connect failed\n");
                ttysetup(speed(BR));
        if (connect()) {
                printf("Connect failed\n");
+               daemon_uid();
                delock(uucplock);
                exit(1);
        }
                delock(uucplock);
                exit(1);
        }