eacces-error.c revision dfa2201c6ac8ddb2d2798dee15662cfe774e644e
/* Copyright (c) 2007-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "path-util.h"
#include "ipwd.h"
#include "restrict-access.h"
#include "eacces-error.h"
#include <unistd.h>
{
unsigned int i, count;
return TRUE;
for (i = 0; i < count; i++) {
return TRUE;
}
return FALSE;
}
{
char c;
switch (mode) {
case R_OK:
c = 'r';
break;
case W_OK:
c = 'w';
break;
case X_OK:
c = 'x';
break;
default:
i_unreached();
}
}
static int
{
bool user_not_in_group = FALSE;
int mode;
return -1;
}
switch (access_mode) {
case R_OK:
mode = 04;
break;
case W_OK:
mode = 02;
break;
case X_OK:
mode = 01;
break;
default:
i_unreached();
}
else {
}
return 0;
if (write_eacces)
if (user_not_in_group) {
/* group would have had enough permissions,
but we don't belong to the group */
}
return -1;
}
{
return 0;
}
} else {
path, access_mode);
}
return -1;
}
/* access() uses real uid, not effective uid.
we'll have to do these checks manually. */
switch (access_mode) {
case X_OK:
return 0;
return 0;
else
return -1;
case R_OK:
case W_OK:
break;
default:
i_unreached();
}
}
static const char *
{
orig_errno = errno;
if (*path != '/') {
if (t_get_current_dir(&dir) == 0) {
}
}
case -1:
break;
case 0:
break;
default:
break;
}
case -1:
break;
case 0:
break;
default:
break;
}
break;
if (ret == 0)
break;
/* see if we have access to parent directory */
/* probably mkdir_parents() failed here, find the first
parent directory we couldn't create */
} else {
/* some other error, can't handle it */
break;
}
}
if (ret == 0) {
/* dir is the first parent directory we can stat() */
missing_mode = 1;
missing_mode = 2;
/* this produces a wrong error if the operation didn't
actually need write permissions, but we don't know
it here.. */
missing_mode = 4;
} else {
}
}
if (ret < 0)
;
} else {
}
} else if (missing_mode != 0 &&
}
}
}
errno = orig_errno;
}
{
}
{
}
{
int orig_errno = errno;
if (gid_origin != NULL)
errno = orig_errno;
}