Ignore:
Timestamp:
Jan 5, 2008, 5:47:19 AM (16 years ago)
Author:
andersk
Message:
Honor .k5login files for users with non-AFS home directories.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/common/oursrc/accountadm/admof.c

    r578 r579  
    2626#include <krb5.h>
    2727#include <kerberosIV/krb.h>
     28#include <stdbool.h>
    2829
    2930extern int pioctl(char *, afs_int32, struct ViceIoctl *, afs_int32);
     
    3536#define OVERLORDS "system:scripts-root"
    3637
    37 static int
     38static bool
    3839ismember(const char *user, const char *group)
    3940{
     
    8889    if (n < 0 || n >= sizeof dir)
    8990        die("internal error\n");
     91
     92    /* For non-AFS homedirs, read the .k5login file. */
     93    if (strncmp(dir, "/afs/", 5) != 0 && strncmp(dir, "/mit/", 5) != 0) {
     94        if (chdir(dir) != 0)
     95            die("internal error: chdir: %m\n");
     96        FILE *fp = fopen(".k5login", "r");
     97        if (fp == NULL)
     98            die("internal error: .k5login: %m\n");
     99        bool found = false;
     100        char *line = NULL;
     101        size_t len = 0;
     102        ssize_t read;
     103        while ((read = getline(&line, &len, fp)) != -1) {
     104            if (read > 0 && line[read - 1] == '\n')
     105                line[read - 1] = '\0';
     106            if (strcmp(name, line) == 0) {
     107                found = true;
     108                break;
     109            }
     110        }
     111        if (line)
     112            free(line);
     113        fclose(fp);
     114        if (found) {
     115            printf("yes\n");
     116            exit(33);
     117        } else {
     118            printf("no\n");
     119            exit(1);
     120        }
     121    }
    90122
    91123    /* Get the locker's cell. */
Note: See TracChangeset for help on using the changeset viewer.