Beispiel #1
0
static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args)
{
	char *filename, *attribute, *tdbname;
	DATA_BLOB blob;
	int blobsize;
	NTSTATUS status;
	TALLOC_CTX *mem_ctx;
	struct tdb_wrap *eadb;

	if (!PyArg_ParseTuple(args, "ssss#", &tdbname, &filename, &attribute, 
						  &blob.data, &blobsize))
		return NULL;

	blob.length = blobsize;
	mem_ctx = talloc_new(NULL);
	eadb = tdb_wrap_open(mem_ctx, tdbname, 50000,
				TDB_DEFAULT, O_RDWR|O_CREAT, 0600);

	if (eadb == NULL) {
		PyErr_SetFromErrno(PyExc_IOError);
		talloc_free(mem_ctx);
		return NULL;
	}
	status = push_xattr_blob_tdb_raw(eadb, mem_ctx, attribute, filename, -1,
									 &blob);
	if (!NT_STATUS_IS_OK(status)) {
		PyErr_FromNTSTATUS(status);
		talloc_free(mem_ctx);
		return NULL;
	}
	talloc_free(mem_ctx);
	Py_RETURN_NONE;
}
Beispiel #2
0
static int posix_eadb_setattr(struct tdb_wrap *db_ctx,
			     const char *fname, int fd, const char *name,
			     const void *value, size_t size, int flags)
{
	NTSTATUS status;
	DATA_BLOB data = data_blob_const(value, size);

	DEBUG(10, ("posix_eadb_setattr called for file %s/fd %d, name %s\n",
		   fname, fd, name));

	status = push_xattr_blob_tdb_raw(db_ctx, name, fname, fd, &data);

	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(10, ("push_xattr_blob_tdb_raw failed: %s\n",
			   nt_errstr(status)));
		return -1;
	}

	return 0;
}