~d-jj/+junk/sudo

« back to all changes in this revision

Viewing changes to sudo.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant, Ongoing Merge Process
  • Date: 2006-06-28 19:59:32 UTC
  • mfrom: (1.1.4 etch)
  • Revision ID: james.westby@ubuntu.com-20060628195932-pqwo7jdpbnzeffsd
Tags: 1.6.8p12-4ubuntu1
[ Ongoing Merge Process ]
Merge from debian unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
515
515
     * "host" is the (possibly fully-qualified) hostname and
516
516
     * "shost" is the unqualified form of the hostname.
517
517
     */
 
518
    sudo_user.host_fqdn_queried = FALSE;
518
519
    nohostname = gethostname(thost, sizeof(thost));
519
520
    if (nohostname)
520
521
        user_host = user_shost = "localhost";
521
522
    else {
522
523
        user_host = estrdup(thost);
523
 
        if (def_fqdn) {
524
 
            /* Defer call to set_fqdn() until log_error() is safe. */
 
524
        if ((p = strchr(user_host, '.'))) {
 
525
            *p = '\0';
 
526
            user_shost = estrdup(user_host);
 
527
            *p = '.';
 
528
        } else {
525
529
            user_shost = user_host;
526
 
        } else {
527
 
            if ((p = strchr(user_host, '.'))) {
528
 
                *p = '\0';
529
 
                user_shost = estrdup(user_host);
530
 
                *p = '.';
531
 
            } else {
532
 
                user_shost = user_host;
533
 
            }
534
530
        }
535
531
    }
536
532
 
571
567
 
572
568
    /* It is now safe to use log_error() and set_perms() */
573
569
 
574
 
    if (def_fqdn)
575
 
        set_fqdn();                     /* may call log_error() */
576
 
 
577
570
    if (nohostname)
578
571
        log_error(USE_ERRNO|MSG_ONLY, "can't get hostname");
579
572
 
 
573
    /* We don't query FQDN yet, it might get disabled later. Querying is done
 
574
     * when host matching is executed and def_fqdn still true */
 
575
 
580
576
    set_runaspw(*user_runas);           /* may call log_error() */
581
577
    if (*user_runas[0] == '#' && runas_pw->pw_name && runas_pw->pw_name[0])
582
578
        *user_runas = estrdup(runas_pw->pw_name);
696
692
        return(rval);
697
693
    }
698
694
 
 
695
    /* New default: reset the environment */
 
696
    def_env_reset = TRUE;
699
697
    while (NewArgc > 0 && NewArgv[0][0] == '-') {
700
698
        if (NewArgv[0][1] != '\0' && NewArgv[0][2] != '\0')
701
699
            warnx("please use single character options");
1015
1013
    struct hostent *hp;
1016
1014
    char *p;
1017
1015
 
 
1016
    if (!def_fqdn || sudo_user.host_fqdn_queried) {
 
1017
        /* Only querying just once is good enough */
 
1018
        return;
 
1019
    }
 
1020
 
1018
1021
    if (!(hp = gethostbyname(user_host))) {
1019
1022
        log_error(MSG_ONLY|NO_EXIT,
1020
1023
            "unable to lookup %s via gethostbyname()", user_host);
1031
1034
    } else {
1032
1035
        user_shost = user_host;
1033
1036
    }
 
1037
    sudo_user.host_fqdn_queried = TRUE;
1034
1038
}
1035
1039
 
1036
1040
/*