From 0b14cdc2701a0363c8960734c2934e0fc135dd0a Mon Sep 17 00:00:00 2001 From: mar Date: Wed, 12 Apr 1989 19:11:42 +0000 Subject: [PATCH] fixed canonicalization of hostnames, and print warning if changing a name --- clients/passwd/chpobox.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/clients/passwd/chpobox.c b/clients/passwd/chpobox.c index 42db1d65..056bf0e7 100644 --- a/clients/passwd/chpobox.c +++ b/clients/passwd/chpobox.c @@ -56,7 +56,7 @@ main(argc, argv) { struct passwd *pwd; char *smsarg[3], buf[BUFSIZ]; - char *potype(); + char *potype(), *index(); char *address, *uname, *machine; uid_t u; char *canonicalize_hostname(); @@ -150,7 +150,7 @@ main(argc, argv) whoami, address); goto show; } - smsarg[2] = canonicalize_hostname(machine); + smsarg[2] = canonicalize_hostname(strsave(machine)); smsarg[1] = potype(smsarg[2]); if (!strcmp(smsarg[1], "POP")) { if (strcmp(address, uname)) { @@ -160,16 +160,21 @@ main(argc, argv) goto show; } } else if (!strcmp(smsarg[1], "LOCAL")) { + strcat(address, "@"); + strcat(address, smsarg[2]); smsarg[2] = address; - *(--machine) = '@'; - address = index(machine, '.'); - if (address == NULL) - address = &machine[strlen(machine)]; - sprintf(address, ".LOCAL"); + if ((address = index(address, '@')) && + (address = index(address, '.'))) + *address = 0; + strcat(smsarg[2], ".LOCAL"); smsarg[1] = "SMTP"; } else if (smsarg[1]) { + if (*machine != '"' && strcasecmp(smsarg[2], machine)) + printf("Warning: hostname %s canonicalized to %s\n", + machine, smsarg[2]); + strcat(address, "@"); + strcat(address, smsarg[2]); smsarg[2] = address; - *(--machine) = '@'; } else goto show; status = sms_query("set_pobox", 3, smsarg, scream, NULL); -- 2.45.2