|
|
1.1 root 1: /*
2: * uucheckname - Check validity of current uucp site name.
3: */
4:
5: #include <ctype.h>
6: #include "uucheck.h"
7: #include "uucheckname.h"
8:
9: uucheckname()
10: {
11: char uucpname[BIG]; /* Uucp name as extracted from /etc/uucpname. */
12: char *str; /* Handy character string walker. */
13:
14: REALLYVERBOSE("\n\nChecking site name...\n");
15:
16: if (gethostname(uucpname, BIG - 1 ) == -1) {
17: FATAL("uucheckname: can't open %s.\n", NAMEFILE);
18: } /* if gethostname failed */
19:
20: REALLYVERBOSE("Testing name length.\n");
21: if (strlen(uucpname) > MAX_NAME) {
22: sprintf(bigbuf, "UUCP name %s is longer than %d characters.\n",
23: uucpname, MAX_NAME);
24: ERROR(bigbuf);
25: sprintf(bigbuf,
26: "UUCP can not handle names longer than %d characters.\n",
27: MAX_NAME);
28: VERBOSE(bigbuf);
29: } else if (strlen(uucpname) > MAX_UNIQUE) {
30: sprintf(bigbuf, "UUCP name %s is longer than %d characters.\n",
31: uucpname, MAX_UNIQUE);
32: WARNING(bigbuf);
33: sprintf(bigbuf,
34: "Those characters beyond the %dth will be ignored.\n",
35: MAX_UNIQUE);
36: VERBOSE(bigbuf);
37: sprintf(bigbuf, "Your sitename will be treated as %.7s.\n", uucpname);
38: VERBOSE(bigbuf);
39: } /* if uucpname is longer than the number of significant characters */
40:
41:
42: REALLYVERBOSE("Checking to see that name is alphanumeric.\n");
43: /* Check to see that uucpname starts alpha. */
44: if (!isalpha(*uucpname)) {
45: sprintf(bigbuf, "%s is an illegal uucp name.\n", uucpname);
46: ERROR(bigbuf);
47: VERBOSE("UUCP names must start with a letter.\n");
48: } else {
49: /* Check to see that uucpname is strictly alphanumeric. */
50: for ( str = uucpname + 1; isalnum(*str); ++str) {
51: /* empty */
52: }
53:
54: if (*str != (char) NULL) {
55: sprintf(bigbuf, "%s is an illegal uucp name.\n", uucpname);
56: ERROR(bigbuf);
57: VERBOSE("Use only letters and numbers, and start with a letter.");
58: } /* If we didn't end on a NULL, we've got an non-alphanumeric character. */
59: } /* if first character of uucpname was not alpha */
60:
61: REALLYVERBOSE("Checking to see that uucpname is strictly lowercase.\n");
62: /* Check to see that uucpname is strictly lowercase. */
63: for ( str = uucpname; islower(*str) || isdigit(*str); ++str) {
64: /* empty */
65: }
66:
67: if (*str != (char) NULL) {
68: sprintf(bigbuf, "%s is contains upper case letters.\n", uucpname);
69: WARNING(bigbuf);
70: VERBOSE("You ought use only lower case letters.\n");
71: } /* If we didn't end on a NULL, we've got an non-alphanumeric character. */
72:
73:
74: REALLYVERBOSE("Checking to see if a well known sitename has been chosen.\n");
75: /* Check to see if a well known sitename has been chosen. */
76: if (lookup(uucpname, well_known_names) != NULL) {
77: sprintf(bigbuf, "%s is a very well known site.\n", uucpname);
78: WARNING(bigbuf);
79: VERBOSE("You REALLY should pick a different name...\n");
80: VERBOSE("Unless, of course, you really are who you claim to be.\n");
81: FIX(MESSAGE("Call Technical Support for name ideas.\n"));
82: } /* if uucpname is a well-known site */
83:
84:
85: if (fix) {
86: /* If this is not a silent session, try to get a new
87: * uucpname from the user.
88: */
89: if (!silent) {
90: if (error) {
91: /* Pick a new name unconditionally on error. */
92: recreate_uucpname();
93: } else if (warning) {
94: /* Otherwise, the user gets to choose. */
95: printf("Do you want to enter a new uucpname (y/n)? ");
96: if (get_yes_or_no()) {
97: recreate_uucpname();
98: } /* if (get_yes_or_no()) */
99: } /* if (error) else if (warning) */
100: } /* if (!silent) */
101: } /* if (fix) */
102:
103: RETURN;
104: } /* uucheckname */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.