예제 #1
0
파일: sid2name.c 프로젝트: 99years/plan9
void
upd_names(Session *s, Share *sp, char *path, Dir *d)
{
	int fh, result;
	char *usid, *gsid;
	FInfo fi;

	if(d->uid)
		free(d->uid);
	if(d->gid)
		free(d->gid);

	if((fh = CIFS_NT_opencreate(s, sp, path, 0, 0, 0, READ_CONTROL,
	    FILE_SHARE_ALL, FILE_OPEN, &result, &fi)) == -1){
		d->uid = estrdup9p("unknown");
		d->gid = estrdup9p("unknown");
		return;
	}
	usid = nil;
	gsid = nil;
	TNTquerysecurity(s, sp, fh, &usid, &gsid);
	d->uid = sid2name(usid);
	d->gid = sid2name(gsid);
	if(fh != -1)
		CIFSclose(s, sp, fh);
}
예제 #2
0
파일: main.c 프로젝트: Nurb432/plan9front
/* Uncle Bill, you have a lot to answer for... */
static int
ntcreateopen(Aux *a, char *path, int mode, int perm, int is_create,
	int is_dir, FInfo *fip)
{
	int options, result, attrs, flags, access, action, share;

	if(mode & DMAPPEND){
		werrstr("CIFSopen, DMAPPEND not supported");
		return -1;
	}

	if(is_create){
		if(mode & OEXCL)
			action = FILE_OPEN;
		else if(mode & OTRUNC)
			action = FILE_CREATE;
		else
			action = FILE_OVERWRITE_IF;
	} else {
		if(mode & OTRUNC)
			action = FILE_OVERWRITE_IF;
		else
			action = FILE_OPEN_IF;
	}

	flags = 0;		/* FIXME: really not sure */

	if(mode & OEXCL)
		share = FILE_NO_SHARE;
	else
		share = FILE_SHARE_ALL;

	switch (mode & OMASK){
	case OREAD:
		access = GENERIC_READ;
		break;
	case OWRITE:
		access = GENERIC_WRITE;
		break;
	case ORDWR:
		access = GENERIC_ALL;
		break;
	case OEXEC:
		access = GENERIC_EXECUTE;
		break;
	default:
		werrstr("%d bad open mode", mode & OMASK);
		return -1;
		break;
	}

	if(is_dir){
		action = FILE_CREATE;
		options = FILE_DIRECTORY_FILE;
		if(perm & 0222)
			attrs = ATTR_DIRECTORY;
		else
			attrs = ATTR_DIRECTORY|ATTR_READONLY;
	} else {
		options = FILE_NON_DIRECTORY_FILE;
		if(perm & 0222)
			attrs = ATTR_NORMAL;
		else
			attrs = ATTR_NORMAL|ATTR_READONLY;
	}

	if(mode & ORCLOSE){
		options |= FILE_DELETE_ON_CLOSE;
		attrs |= ATTR_DELETE_ON_CLOSE;
	}

	if((a->fh = CIFS_NT_opencreate(Sess, a->sp, path, flags, options,
	    attrs, access, share, action, &result, fip)) == -1)
		return -1;

	if((mode & OEXCL) && (result & 0x8000) == 0){
		werrstr("%d bad open mode", mode & OMASK);
		return -1;
	}

	return 0;
}