Exemplo n.º 1
0
void init(struct bot *bot) {
	mkfifo("status", 0644);
	if (!isfifo("status")) {
		printf("[fifo\tfail] Error initializing status FIFO: %s\n", strerror(errno));
	} else {
		push_val(bot->tick_functions, fifo_tick);
	}
}
Exemplo n.º 2
0
boolean
make_fifo(char *fifo_path)
    {
    boolean		fifo_exists;

	if ((fifo_exists = isfifo(fifo_path)) == FALSE)
		{
        if (mkfifo(fifo_path, 0664) < 0)
		    log_printf("Make fifo %s failed: %m\n", fifo_path);
		else
			fifo_exists = TRUE;
		}
	if (fifo_exists)
		check_modes(fifo_path, 0664);
	return fifo_exists;
	}
Exemplo n.º 3
0
char *getmodes(File *file)
{
    char *unknownmodes = "???????????";
    char *modes = malloc((strlen(unknownmodes) + 1) * sizeof(*modes));
    if (!modes) {
        return strdup(unknownmodes);
    }
    struct stat *pstat = getstat(file);
    if (!pstat) {
        free(modes);
        return strdup(unknownmodes);
    }

    char *p = modes;
    if (islink(file))
        *p++ = 'l';
    else if (isdir(file))
        *p++ = 'd';
    else if (isblockdev(file))
        *p++ = 'b';
    else if (ischardev(file))
        *p++ = 'c';
    else if (isfifo(file))
        *p++ = 'p';
    else if (issock(file))
        *p++ = 's';
    else
        *p++ = '-';

    if (pstat->st_mode & S_IRUSR)
        *p++ = 'r';
    else
        *p++ = '-';

    if (pstat->st_mode & S_IWUSR)
        *p++ = 'w';
    else
        *p++ = '-';

    if (issetuid(file)) {
        if (pstat->st_mode & S_IXUSR)
            *p++ = 's';
        else
            *p++ = 'S';
    } else {
        if (pstat->st_mode & S_IXUSR)
            *p++ = 'x';
        else
            *p++ = '-';
    }

    if (pstat->st_mode & S_IRGRP)
        *p++ = 'r';
    else
        *p++ = '-';

    if (pstat->st_mode & S_IWGRP)
        *p++ = 'w';
    else
        *p++ = '-';

    if (issetgid(file)) {
        if (pstat->st_mode & S_IXGRP)
            *p++ = 's';
        else
            *p++ = 'S';
    } else {
        if (pstat->st_mode & S_IXGRP)
            *p++ = 'x';
        else
            *p++ = '-';
    }

    if (pstat->st_mode & S_IROTH)
        *p++ = 'r';
    else
        *p++ = '-';

    if (pstat->st_mode & S_IWOTH)
        *p++ = 'w';
    else
        *p++ = '-';

    if (issticky(file)) {
        if (pstat->st_mode & S_IXOTH)
            *p++ = 't';
        else
            *p++ = 'T';
    } else {
        if (pstat->st_mode & S_IXOTH)
            *p++ = 'x';
        else
            *p++ = '-';
    }

    /* POSIX says we should print a space if there are no extended ACLs,
       GNU ls prints nothing
       follow POSIX */
    if (!islink(file) && hasacls(file))
        *p++ = '+';
    else
        *p++ = ' ';

    *p++ = '\0';
    return modes;
}