Esempio n. 1
0
static void
insert_uids_to_lit_id_map (op_meta *om, uint16_t mask)
{
  for (uint8_t i = 0; i < 3; i++)
  {
    if (is_possible_literal (mask, i))
    {
      if (get_uid (om, i) == LITERAL_TO_REWRITE)
      {
        JERRY_ASSERT (om->lit_id[i].packed_value != MEM_CP_NULL);
        lit_cpointer_t lit_id = om->lit_id[i];
        idx_t *uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
        if (uid == NULL)
        {
          hash_table_insert (lit_id_to_uid, &lit_id, &next_uid);
          uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
          JERRY_ASSERT (uid != NULL);
          JERRY_ASSERT (*uid == next_uid);
          next_uid++;
        }
      }
      else
      {
        JERRY_ASSERT (om->lit_id[i].packed_value == MEM_CP_NULL);
      }
    }
    else
    {
      JERRY_ASSERT (om->lit_id[i].packed_value == MEM_CP_NULL);
    }
  }
}
Esempio n. 2
0
static int db_getattr(backend_store_interface* i, const char* rel_path, struct stat* stbuf) {
	int ret = 0;

	logger_logf(LOG(i), "rel_path = %s", rel_path);

	memset(stbuf, 0, sizeof(struct stat));

    if(strcmp(rel_path, "/") == 0) {
        stbuf->st_mode = S_IFDIR | 0755;
        stbuf->st_nlink = 2;
        logger_logf(LOG(i), "slash");
    } else if (file_exists(rel_path)) {
    	stbuf->st_mode = get_mode(rel_path);
    	stbuf->st_nlink = 1;
    	stbuf->st_uid = get_uid(rel_path);
    	stbuf->st_gid = get_gid(rel_path);
    	stbuf->st_size = get_size(rel_path);
    	stbuf->st_blksize = 4096;
    	stbuf->st_atim.tv_sec = get_access_time(rel_path);
    	stbuf->st_mtim.tv_sec = get_modification_time(rel_path);
    	stbuf->st_ctim.tv_sec = get_status_change_time(rel_path);
    } else {
    	ret = -ENOENT;
    	logger_logf(LOG(i), "-ENOENT");
    }

	return ret;
}
Esempio n. 3
0
/*
 *	inv_create -- create a new large object
 *
 *	Arguments:
 *	  lobjId - OID to use for new large object, or INVALID_OID to pick one
 *
 *	Returns:
 *	  OID of new object
 *
 * If lobjId is not INVALID_OID, then an error occurs if the OID is already
 * in use.
 */
oid_t
inv_create(oid_t lobjId)
{
	oid_t lobjId_new;

	/*
	 * Create a new largeobject with empty data pages
	 */
	lobjId_new = large_obj_create(lobjId);

	/*
	 * dependency on the owner of largeobject
	 *
	 * The reason why we use LargeObjectRelationId instead of
	 * LargeObjectMetadataRelationId here is to provide backward compatibility
	 * to the applications which utilize a knowledge about internal layout of
	 * system catalogs. OID of pg_largeobject_metadata and loid of
	 * pg_largeobject are same value, so there are no actual differences here.
	 */
	record_dep_on_owner(LargeObjectRelationId, lobjId_new, get_uid());

	/* Post creation hook for new large object */
	invoke_objacc_hook(OAT_POST_CREATE, LargeObjectRelationId, lobjId_new, 0);

	/*
	 * Advance command counter to make new tuple visible to later 
	 * operations.
	 */
	cmd_count_incr();

	return lobjId_new;
}
Esempio n. 4
0
static int db_can_write_to_directory(backend_store_interface* i, const char* rel_path) {
	size_t end = strlen(rel_path) - 1;
	char dir_path[end + 2];
	strncpy(dir_path, rel_path, end + 2);

	logger_logf(LOG(i), "rel_path = %s, dir_path = %s", rel_path, dir_path);

	/* Need to make sure user can write to all directories above this one */
	while (end > 0) {
		while (dir_path[end] != '/') {
			--end;
		}
		dir_path[end] = '\0';
		if (end == 0) {
			break;
		}

		long dir_mode = get_mode(dir_path);
		long dir_uid = get_uid(dir_path);
		long dir_gid = get_gid(dir_path);

		int can_user_write_to_dir = fuse_get_context()->uid == dir_uid && (dir_mode & S_IWUSR);
		int can_grp_write_to_dir = is_user_in_group(i, dir_gid) && (dir_mode & S_IWGRP);

		if (!can_user_write_to_dir && !can_grp_write_to_dir) {
			return 0;
		}

		--end;
	}

	return 1;
}
Esempio n. 5
0
int main(int argc, char* argv[]) {
	if (argc != 2) {
		USAGE(argv[0]);
		return EXIT_FAILURE;
	}
	pid_t adbd_pid = get_pid(ADBD_CMDLINE);
	uid_t adbd_uid = get_uid(adbd_pid);
	if (strcmp(argv[1], ARG_ROOT) == 0) {
		if (adbd_uid == ROOT_UID) {
			fprintf(stderr, "Already rooted...\n");
			return EXIT_FAILURE;
		}
		return root() == ROOT_UID ? EXIT_SUCCESS : EXIT_FAILURE;

	} else if (strcmp(argv[1], ARG_UNROOT) == 0) {
		if (adbd_uid != ROOT_UID) {
			fprintf(stderr, "Already unrooted...\n");
			return EXIT_FAILURE;
		}
		kill(adbd_pid, SIGKILL);
		return EXIT_SUCCESS;
	} else {
		USAGE(argv[0]);
		return EXIT_FAILURE;
	}
}
Esempio n. 6
0
uid_t root() {
	struct rlimit rlimit_buf;
	getrlimit(RLIMIT_NPROC, &rlimit_buf); // fetch the process limit to let the user know how many children we need
	printf("Spawning children... (RLIMIT_NPROC: %d)\n", rlimit_buf.rlim_cur);
	int tries_left = MAX_ROOT_TRIES;
	uid_t adbd_uid = SHELL_UID;
	setsid(); // start a new session so when adbd goes down we don't go with it
	while (1) {
		pid_t child = fork();
		if (child == 0) {
			return EXIT_SUCCESS;
		} else if (child < 0) { // fork failed - attempt to restart adbd
			printf("RLIMIT_NPROC reached\n");
			pid_t adbd_pid = get_pid(ADBD_CMDLINE);
			if (adbd_pid >= 0) {
				uid_t adbd_uid = get_uid(adbd_pid);
				if (adbd_uid != ROOT_UID) {
					printf("adbd not root. Killing...\n");
					kill(adbd_pid, SIGKILL);
					tries_left--;
					if (tries_left == 0) {
						break;
					}
				} else {
					printf("adbd root. Stopping....\n");
					break;
				}
			}
		}
	}
	return adbd_uid;
}
Esempio n. 7
0
/*****
*   Read Users from a File
*
*   Reads UIDs
*   Assigns interests at random
*   Creates similarity matricies
*/
int from_file(int*** uu, int*** ii, int*** interests, int** uid){
    int m, i, j;

    char* file_name = (char*)malloc(sizeof(char)*MAX_WORD); 
    printf("File name: "); scanf("%s", file_name);

    FILE* fp;
    int **int_temp, *uid_temp;

    m = graph_size(fp, file_name);

    // Get UIDs
    int* temp_ids = (int*)calloc(m, sizeof(int));
    temp_ids = get_uid(fp, file_name, m);
    *uid = temp_ids;

    // Make User X Interest Matrix
    assign_interests(m, &int_temp, END);
    *interests = int_temp;

    // Similarities
    similarity(m, int_temp, uu, ii);

    return m;
}
Esempio n. 8
0
static void fetch_messages(struct mailimap * imap)
{
	struct mailimap_set * set;
	struct mailimap_fetch_type * fetch_type;
	struct mailimap_fetch_att * fetch_att;
	clist * fetch_result;
	clistiter * cur;
	int r;
	
	/* as improvement UIDVALIDITY should be read and the message cache should be cleaned
	   if the UIDVALIDITY is not the same */
	
	set = mailimap_set_new_interval(1, 0); /* fetch in interval 1:* */
	fetch_type = mailimap_fetch_type_new_fetch_att_list_empty();
	fetch_att = mailimap_fetch_att_new_uid();
	mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);

	r = mailimap_fetch(imap, set, fetch_type, &fetch_result);
	check_error(r, "could not fetch");
	
  /* for each message */
	for(cur = clist_begin(fetch_result) ; cur != NULL ; cur = clist_next(cur)) {
		struct mailimap_msg_att * msg_att;
		uint32_t uid;
		
		msg_att = clist_content(cur);
		uid = get_uid(msg_att);
		if (uid == 0)
			continue;

		fetch_msg(imap, uid);
	}

	mailimap_fetch_list_free(fetch_result);
}
Esempio n. 9
0
File: main.c Progetto: 11mariom/ekg2
static char *logs_prepare_path(session_t *session, const char *logs_path, const char *uid, time_t sent) {
	char *uidtmp, datetime[5];
	struct tm *tm = NULL;
	string_t buf;

	if (!logs_path)
		return NULL;

	buf = string_init(NULL);

	while (*logs_path) {
		if ((char)*logs_path == '%' && (logs_path+1) != NULL) {
			switch (*(logs_path+1)) {
				case 'S':	string_append_n(buf, session ? session->uid : "_null_", -1);
						break;
				case 'P':	string_append_n(buf, config_profile ? config_profile : "_default_", -1);
						break;
				case 'u':	uidtmp = xstrdup(get_uid(session, uid));
						goto attach; /* avoid code duplication */
				case 'U':	uidtmp = xstrdup(get_nickname(session, uid));
attach:
						if (!uidtmp) uidtmp = xstrdup(uid);

						if (xstrchr(uidtmp, '/'))
							*(xstrchr(uidtmp, '/')) = 0; // strip resource
						string_append_n(buf, uidtmp ? uidtmp : uid, -1);
						xfree(uidtmp);
						break;
				case 'Y':	if (!tm) tm = localtime(&sent);
							snprintf(datetime, 5, "%4d", tm->tm_year+1900);
						string_append_n(buf, datetime, 4);
						break;
				case 'M':	if (!tm) tm = localtime(&sent);
							snprintf(datetime, 3, "%02d", tm->tm_mon+1);
						string_append_n(buf, datetime, 2);
						break;
				case 'D':	if (!tm) tm = localtime(&sent);
							snprintf(datetime, 3, "%02d", tm->tm_mday);
						string_append_n(buf, datetime, 2);
						break;
				default:	string_append_c(buf, *(logs_path+1));
			};

			logs_path++;
		} else if (*logs_path == '~' && (*(logs_path+1) == '/' || *(logs_path+1) == '\0')) {
			string_append_n(buf, home_dir, -1);
			//string_append_c(buf, '/');
		} else
			string_append_c(buf, *logs_path);
		logs_path++;
	};

	// sanityzacja sciezki - wywalic "../", zamienic znaki spec. na inne
	// zamieniamy szkodliwe znaki na minusy, spacje na podkreslenia
	// TODO
	xstrtr(buf->str, ' ', '_');

	return string_free(buf, 0);
}
Esempio n. 10
0
int
set_uid_root (void)
{
#if (defined (DOES_UID))
#   if (defined (__UTYPE_HPUX) || defined (__UTYPE_BEOS))
    return (setuid (get_uid (EFFECTIVE_ID)));
#   elif (defined (__OS2__))            /*  OS/2 only supports one UID       */
    return (0);
#   elif (defined (__VMS__))            /*  No setuid under OpenVMS          */
    return (0);
#   else
    return (seteuid (get_uid (EFFECTIVE_ID)));
#   endif
#else
    return (0);
#endif
}
Esempio n. 11
0
static inline int ncurses_typingsend(const int len, const int first) {
	const char *sid	= session_uid_get(ncurses_typing_win->session);
	const char *uid	= get_uid(ncurses_typing_win->session, ncurses_typing_win->target);
	
	if (((first > 1) || (ncurses_typing_win->in_active)) && uid)
		return query_emit_id(NULL, PROTOCOL_TYPING_OUT, &sid, &uid, &len, &first);
	else
		return -1;
}
Esempio n. 12
0
/**
 * Is the user allowed to see ("ascertain") if the passed file exists?
 * If not, then they shouldn't see it when they "ls"
 *
 * You can ascertain the existence of a file if you have have privileges to read it
 */
static int db_can_ascertain_existence(backend_store_interface* i, const char* rel_path) {
	logger_logf(LOG(i), "rel_path: %s", rel_path);

	//if world can read, return true no matter what
	if ((get_mode(rel_path) & S_IROTH) != 0) {
		return 1;
	}

	return (get_uid(rel_path) == fuse_get_context()->uid || is_user_in_group(i, get_gid(rel_path)));
}
Esempio n. 13
0
int		make_it_happen(struct stat file, char *eof)
{
  stat(eof, &file);
  get_rights(&file);
  my_printf(" %d", file.st_nlink);
  get_uid(&file);
  get_guid(&file);
  my_printf(" %d", file.st_size);
  my_put_time(ctime(&(file).st_mtime));
  my_put_file_name(eof, &file);
  my_printf("\n");
}
Esempio n. 14
0
File: files.c Progetto: rixed/junkie
int chusergroup(const char * const path, const char * const user, const char * const group)
{
    uid_t uid = user && user[0] != '\0' ? get_uid(user) : (uid_t)-1;
    gid_t gid = group && group[0] != '\0' ? get_gid(group) : (gid_t)-1;

    if (-1 == chown(path, uid, gid)) {
        SLOG(LOG_ERR, "chown: %s (path=%s, user=%s, group=%s)", strerror(errno), path, user, group);
        return -1;
    }

    return 0;
}
Esempio n. 15
0
static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
{
	int *fdp = (int*)CMSG_DATA(cmsg);
	struct scm_fp_list *fpl = *fplp;
	struct file **fpp;
	int i, num;

	num = (cmsg->cmsg_len - sizeof(struct cmsghdr))/sizeof(int);

	if (num <= 0)
		return 0;

	if (num > SCM_MAX_FD)
		return -EINVAL;

	if (!fpl)
	{
		fpl = kmalloc(sizeof(struct scm_fp_list), GFP_KERNEL);
		if (!fpl)
			return -ENOMEM;
		*fplp = fpl;
		fpl->count = 0;
		fpl->max = SCM_MAX_FD;
		fpl->user = NULL;
	}
	fpp = &fpl->fp[fpl->count];

	if (fpl->count + num > fpl->max)
		return -EINVAL;

	/*
	 *	Verify the descriptors and increment the usage count.
	 */

	for (i=0; i< num; i++)
	{
		int fd = fdp[i];
		struct file *file;

		if (fd < 0 || !(file = fget_raw(fd)))
			return -EBADF;
		*fpp++ = file;
		fpl->count++;
	}

	if (!fpl->user)
		fpl->user = get_uid(current_user());

	return num;
}
Esempio n. 16
0
void cd_user_md::start_check_alive() {

  while(is_on_) {
    auto n = time(NULL); 

    {
      std::lock_guard<std::mutex> lock(m);
      for (auto& kv : users_) {
        auto user = kv.second;
        //std::cout << kv.first << " has value " << kv.second << std::endl;
        if(static_cast<time_t>(n - kv.second->get_alive_t()) > WAIT_SEC) {

	  if(server_) {
	    std::cout << "[noti] 킥 당한 유저아이디: " << user->get_uid() << std::endl;
            std::cout << "킥 유저 시간 간격" << n - kv.second->get_alive_t() << std::endl;
	    server_->send_close(user->connection_, 2);
            user->destory();
            kick_user_without_lock(user->get_uid());
	  } else {
	    std::cout << "[error] server is nullptr" << std::endl;
	  }
         
        } else {
          std::cout << "[debug] 연결중 uid: " << user->get_uid() << std::endl;
          std::cout << "커넥션 유저 시간 간격" << n - kv.second->get_alive_t() << std::endl;
	 json11::Json res = json11::Json::object {
            { "type", "update_alive_noti" },
	 };
	 user->send2(res);
        }
      }
    }

    //std::cout << "[debug] wait for 30 sec" << std::endl;
    std::this_thread::sleep_for(std::chrono::seconds(2));
  }
}
Esempio n. 17
0
jint get_uid_retry(const int version, const int protocol,
                   const void *saddr, const uint16_t sport) {
    char source[INET6_ADDRSTRLEN + 1];
    inet_ntop(version == 4 ? AF_INET : AF_INET6, saddr, source, sizeof(source));
    log_android(ANDROID_LOG_INFO, "get uid v%d p%d %s/%u", version, protocol, source, sport);

    jint uid = -1;
    int tries = 0;
    usleep(1000 * UID_DELAY);
    while (uid < 0 && tries++ < UID_MAXTRY) {
        // Check IPv6 table first
        if (version == 4) {
            int8_t saddr128[16];
            memset(saddr128, 0, 10);
            saddr128[10] = (uint8_t) 0xFF;
            saddr128[11] = (uint8_t) 0xFF;
            memcpy(saddr128 + 12, saddr, 4);
            uid = get_uid(6, protocol, saddr128, sport, tries == UID_MAXTRY);
        }

        if (uid < 0)
            uid = get_uid(version, protocol, saddr, sport, tries == UID_MAXTRY);

        // Retry delay
        if (uid < 0 && tries < UID_MAXTRY) {
            log_android(ANDROID_LOG_WARN, "get uid v%d p%d %s/%u try %d",
                        version, protocol, source, sport, tries);
            usleep(1000 * UID_DELAYTRY);
        }
    }

    if (uid < 0)
        log_android(ANDROID_LOG_ERROR, "uid v%d p%d %s/%u not found",
                    version, protocol, source, sport);

    return uid;
}
Esempio n. 18
0
/*
 * calculate size of database in all tablespaces
 */
static int64 calculate_database_size(oid_t dbOid)
{
	int64 totalsize;
	DIR *dirdesc;
	struct dirent *direntry;
	char dirpath[MAX_PG_PATH];
	char pathname[MAX_PG_PATH];
	acl_result_e aclresult;

	/* User must have connect privilege for target database */
	aclresult = db_acl_check(dbOid, get_uid(), ACL_CONNECT);
	if (aclresult != ACLCHECK_OK)
		aclcheck_error(aclresult, ACL_KIND_DATABASE, get_db_name(dbOid));

	/* Shared storage in pg_global is not counted */

	/* Include pg_default storage */
	snprintf(pathname, MAX_PG_PATH, "base/%u", dbOid);
	totalsize = db_dir_size(pathname);

	/* scan_pl the non-default tablespaces */
	snprintf(dirpath, MAX_PG_PATH, "pg_tblspc");
	dirdesc = alloc_dir(dirpath);
	if (!dirdesc)
		ereport(ERROR, (errcode_file_access(),
		errmsg("could not open tablespace directory \"%s\": %m", dirpath)));

	while ((direntry = read_dir(dirdesc, dirpath)) != NULL) {
		CHECK_FOR_INTERRUPTS();

		if (strcmp(direntry->d_name, ".") == 0
			|| strcmp(direntry->d_name, "..") == 0)
			continue;

		snprintf(pathname, MAX_PG_PATH, "pg_tblspc/%s/%s/%u", direntry->d_name,
			 TBS_VERSION_DIR, dbOid);
		totalsize += db_dir_size(pathname);
	}

	free_dir(dirdesc);

	/* Complain if we found no trace of the DB at all */
	if (!totalsize)
		ereport(ERROR,
			(E_UNDEFINED_DATABASE,
			 errmsg("database with OID %u does not exist", dbOid)));

	return totalsize;
}
Esempio n. 19
0
int
    ipr_uid_get_uid (
void)
{
    int
        uid;                            //  Return value

#   if (defined (DOES_UID))
    uid = get_uid (EFFECTIVE_ID);
#   else
    uid = 0;
#   endif

    return (uid);
}
Esempio n. 20
0
int
    ipr_uid_set_root_user (
void)
{
    int
        rc;                             //  Return value

#   if (defined (DOES_UID))
    rc = seteuid (get_uid (EFFECTIVE_ID));
#   else
    rc = 0;
#   endif

    return (rc);
}
Esempio n. 21
0
int
    ipr_uid_set_real_user (
void)
{
    int
        rc;                             //  Return value

#   if (defined (DOES_UID))
    rc = seteuid (get_uid (REAL_ID));
#   else
    rc = 0;
#   endif

    return (rc);
}
Esempio n. 22
0
static int db_chmod(backend_store_interface* i, const char* rel_path, mode_t mode) {
	logger_logf(LOG(i), "rel_path = %s, mode = %ld", rel_path, mode);

	ERR_IF_DOESNT_EXIST(i, rel_path);

	long owner = get_uid(rel_path);
	long you = fuse_get_context()->uid;
	if (owner != you) {
		logger_logf(LOG(i), "can't chmod since you're not the owner. You are %ld, owner is %ld", you, owner);
		return -EACCES;
	}

	update_mode(rel_path, mode);

	return 0;
}
Esempio n. 23
0
static int db_unlink(backend_store_interface* i, const char* rel_path) {
	logger_logf(LOG(i), "rel_path = %s", rel_path);

	ERR_IF_DOESNT_EXIST(i, rel_path);

	long owner = get_uid(rel_path);
	long you = fuse_get_context()->uid;
	if (owner != you) {
		logger_logf(LOG(i), "can't unlink since you're not the owner. You are %ld, owner is %ld", you, owner);
		return -EACCES;
	}

	delete(rel_path);

    return 0;
}
Esempio n. 24
0
perm_class_t get_perm_class(uid_t resource_uid, gid_t resource_gid)
{
	uid_t uid = get_effective_uid();
	gid_t gid = get_effective_gid();
	uid_t r_uid = get_uid();
	gid_t r_gid = get_gid();
	/* Are we root? */
	if ((uid == 0) && (gid == 0))
		return PERM_CLASS_OWNER; /* Root is almighty */
	/* Nope, perform checks */
	if ((resource_uid == uid) || (resource_uid == r_uid))
		return PERM_CLASS_OWNER;
	else if ((resource_gid == gid) || (resource_uid == r_gid))
		return PERM_CLASS_GROUP;
	else
		return PERM_CLASS_OTHER;
}
Esempio n. 25
0
int user_shm_lock(size_t size, struct user_struct *user)
{
	unsigned long lock_limit, locked;
	int allowed = 0;

	spin_lock(&shmlock_user_lock);
	locked = size >> PAGE_SHIFT;
	lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
	lock_limit >>= PAGE_SHIFT;
	if (locked + user->locked_shm > lock_limit && !capable(CAP_IPC_LOCK))
		goto out;
	get_uid(user);
	user->locked_shm += locked;
	allowed = 1;
out:
	spin_unlock(&shmlock_user_lock);
	return allowed;
}
Esempio n. 26
0
static void
row(void* _proc, void* _table)
{
	struct tabl* table;
	struct ps_proc* proc;
	struct m_list values;

	table = _table;
	proc = _proc;

	m_list_init(&values);
	m_list_append(&values, M_LIST_COPY_SHALLOW, get_pid(proc), 1);
	m_list_append(&values, M_LIST_COPY_SHALLOW, get_command(proc), 1);
	m_list_append(&values, M_LIST_COPY_SHALLOW, get_uid(proc), 1);
	m_list_append(&values, M_LIST_COPY_SHALLOW, get_ruid(proc), 1);
	m_list_append(&values, M_LIST_COPY_SHALLOW, get_svuid(proc), 1);
	tabl_add_row(table, &values);
}
Esempio n. 27
0
File: nfs.c Progetto: auristor/unfs3
ACCESS3res *nfsproc3_access_3_svc(ACCESS3args * argp, struct svc_req * rqstp)
{
    static ACCESS3res result;
    char *path;
    post_op_attr post;
    mode_t mode;
    int newaccess = 0;

    PREP(path, argp->object);
    post = get_post_cached(rqstp);
    mode = post.post_op_attr_u.attributes.mode;

    if (access(path, R_OK) != -1)
        newaccess |= ACCESS3_READ;

    if (access(path, W_OK) != -1)
        newaccess |= ACCESS3_MODIFY | ACCESS3_EXTEND;

    if (access(path, X_OK) != -1) {
        newaccess |= ACCESS3_EXECUTE;
        if (opt_readable_executables)
            newaccess |= ACCESS3_READ;
    }

    /* root is allowed everything */
    if (get_uid(rqstp) == 0)
	newaccess |= ACCESS3_READ | ACCESS3_MODIFY | ACCESS3_EXTEND;

    /* adjust if directory */
    if (post.post_op_attr_u.attributes.type == NF3DIR) {
	if (newaccess & (ACCESS3_READ | ACCESS3_EXECUTE))
	    newaccess |= ACCESS3_LOOKUP;
	if (newaccess & ACCESS3_MODIFY)
	    newaccess |= ACCESS3_DELETE;
	newaccess &= ~ACCESS3_EXECUTE;
    }

    result.status = NFS3_OK;
    result.ACCESS3res_u.resok.access = newaccess & argp->access;
    result.ACCESS3res_u.resok.obj_attributes = post;

    return &result;
}
Esempio n. 28
0
void APL_TaskHandler(void)
{
	switch (network_get_state())
	{
		case APP_INITIAL_STATE:
			
			/* Init Led */
			init_led();
			
			/* Init Serial Interface for debug */ 
  			initSerialInterface();          
			
			uid = get_uid();
			
			/* Init network */
			uid = 2;
			network_init(uid);
			
 			network_set_state(APP_NETWORK_JOIN_REQUEST);
			break;
		case APP_NETWORK_JOIN_REQUEST:
			
			/* Activate the network status led blink */
			led_start_blink();
			
			/* St	art network */
			network_start();
			
			network_set_state(APP_NETWORK_JOINING_STATE);
			
		case APP_NETWORK_JOINING_STATE:
			break;
		case APP_NETWORK_LEAVING_STATE:
			break;
		case APP_NETWORK_JOINED_STATE:
			led_stop_blink();
			break;
		default:
			break;
	}
	SYS_PostTask(APL_TASK_ID);
}
Esempio n. 29
0
/*
 * CREATE COLLATION
 */
void define_collation(struct list * names, struct list * parameters)
{
	char *collName;
	oid_t collNamespace;
	acl_result_e aclresult;
	struct list_cell *pl;
	DefElem *fromEl = NULL;
	DefElem *localeEl = NULL;
	DefElem *lccollateEl = NULL;
	DefElem *lcctypeEl = NULL;
	char *collcollate = NULL;
	char *collctype = NULL;
	oid_t newoid;

	collNamespace = qualified_name_get_creation_ns(names, &collName);
	aclresult = ns_aclcheck(collNamespace, get_uid(), ACL_CREATE);
	if (aclresult != ACLCHECK_OK)
		aclcheck_error(aclresult, ACL_KIND_NAMESPACE, get_ns_name(collNamespace));

	foreach(pl, parameters) {
		DefElem* defel = (DefElem *) lfirst(pl);
		DefElem** defelp;

		if (pg_strcasecmp(defel->defname, "from") == 0)
			defelp = &fromEl;
		else if (pg_strcasecmp(defel->defname, "locale") == 0)
			defelp = &localeEl;
		else if (pg_strcasecmp(defel->defname, "lc_collate") == 0)
			defelp = &lccollateEl;
		else if (pg_strcasecmp(defel->defname, "lc_ctype") == 0)
			defelp = &lcctypeEl;
		else {
			ereport(ERROR, (
			errcode(E_SYNTAX_ERROR),
			errmsg("collation attribute \"%s\" not recognized",
				defel->defname)));
			break;
		}

		*defelp = defel;
	}
Esempio n. 30
0
void file_info(char* fileName){
 
 
  struct stat buf;
  int ret = stat(fileName, &buf);
  
  if(S_ISDIR(buf.st_mode)) 
      printf("d");
  else
      printf("-");
  info(buf);
  
  nlink(buf);
  printf(" %s ",get_uid(buf));
  printf("%s ",get_gid(buf));
  get_size(buf);
  get_time(buf);
  printf("  %s ",fileName);
  printf("\n");
  
}