Esempio n. 1
0
bool
check_permission(void)
{
	FILE *fp;
	uid_t uid = geteuid();
	struct passwd *pentry;

	if (uid == 0)
		return true;

	if ((pentry = getpwuid(uid)) == NULL) {
		perror("Cannot access user database");
		exit(EXIT_FAILURE);
	}

	privs_enter();

	fp = fopen(_PATH_AT_ALLOW, "r");

	privs_exit();

	if (fp != NULL) {
		return check_for_user(fp, pentry->pw_name);
	} else {
		privs_enter();

		fp = fopen(_PATH_AT_DENY, "r");

		privs_exit();

		if (fp != NULL)
			return !check_for_user(fp, pentry->pw_name);
	}
	return false;
}
Esempio n. 2
0
/* Global functions */
int check_permission(void)
{
    FILE *fp;
    uid_t uid = geteuid();
    struct passwd *pentry;

    if (uid==0)
	return 1;

    if ((pentry = getpwuid(uid)) == NULL)
	err(EXIT_FAILURE, "cannot access user database");

    PRIV_START

    fp=fopen(PERM_PATH "at.allow","r");

    PRIV_END

    if (fp != NULL)
    {
	return check_for_user(fp, pentry->pw_name);
    }
    else if (errno == ENOENT)
    {

	PRIV_START

	fp=fopen(PERM_PATH "at.deny", "r");

	PRIV_END

	if (fp != NULL)
	{
	    return !check_for_user(fp, pentry->pw_name);
	}
	else if (errno != ENOENT)
	    warn("at.deny");
    }
Esempio n. 3
0
/* Global functions */
int 
check_permission()
{
    FILE *fp;
    uid_t uid = geteuid();
    struct passwd *pentry;

    if (uid == 0)
	return 1;

    if ((pentry = getpwuid(uid)) == NULL) {
	perror("Cannot access user database");
	exit(EXIT_FAILURE);
    }
    PRIV_START

	fp = fopen(ETCDIR "/at.allow", "r");

    PRIV_END

    if (fp != NULL) {
	return check_for_user(fp, pentry->pw_name);
    } else {

	PRIV_START

	    fp = fopen(ETCDIR "/at.deny", "r");

	PRIV_END

	if (fp != NULL) {
	    return !check_for_user(fp, pentry->pw_name);
	}
	perror("at.deny");
    }
    return 0;
}