Changeset 880 in openpam


Ignore:
Timestamp:
Jan 9, 2016, 5:52:39 PM (5 years ago)
Author:
Dag-Erling Smørgrav
Message:

Partially revert r871 until a better solution can be found, as it only
works if the file already exists.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t/t_file.c

    r871 r880  
    5656{
    5757        struct t_file *tf;
    58         int fd, dynfn;
     58        int fd;
    5959
    6060        if ((tf = calloc(sizeof *tf, 1)) == NULL)
    6161                err(1, "%s(): calloc()", __func__);
    6262        if (filename) {
    63                 dynfn = 0;
     63                if ((tf->name = strdup(filename)) == NULL)
     64                        err(1, "%s(): strdup()", __func__);
    6465        } else {
    65                 asprintf(&filename, "%s.%lu.%p.tmp",
     66                asprintf(&tf->name, "%s.%lu.%p.tmp",
    6667                    t_progname, (unsigned long)getpid(), (void *)tf);
    67                 if (filename == NULL)
     68                if (tf->name == NULL)
    6869                        err(1, "%s(): asprintf()", __func__);
    69                 dynfn = 1;
    7070        }
    71         if ((fd = open(filename, O_RDWR|O_CREAT|O_TRUNC, 0600)) < 0)
     71        if ((fd = open(tf->name, O_RDWR|O_CREAT|O_TRUNC, 0600)) < 0)
    7272                err(1, "%s(): %s", __func__, tf->name);
    73         if ((tf->name = realpath(filename, NULL)) == NULL)
    74                 err(1, "%s(): realpath()", __func__);
    75         if (dynfn)
    76                 free(filename);
    7773        if ((tf->file = fdopen(fd, "r+")) == NULL)
    7874                err(1, "%s(): fdopen()", __func__);
Note: See TracChangeset for help on using the changeset viewer.