static int smbconf_reg_close(struct smbconf_ctx *ctx)
{
	int ret;

	if (!rpd(ctx)->open) {
		return 0;
	}

	ret = regdb_close();
	if (ret == 0) {
		rpd(ctx)->open = false;
	}
	return ret;
}
/**
 * initialize the registry smbconf backend
 */
static sbcErr smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
{
	WERROR werr = WERR_OK;
	sbcErr err;
	struct security_token *token;

	if (path == NULL) {
		path = KEY_SMBCONF;
	}
	ctx->path = talloc_strdup(ctx, path);
	if (ctx->path == NULL) {
		err = SBC_ERR_NOMEM;
		goto done;
	}

	ctx->data = talloc_zero(ctx, struct reg_private_data);

	werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
	if (!W_ERROR_IS_OK(werr)) {
		DEBUG(1, ("Error creating admin token\n"));
		err = SBC_ERR_UNKNOWN_FAILURE;
		goto done;
	}
	rpd(ctx)->open = false;

	werr = registry_init_smbconf(path);
	if (!W_ERROR_IS_OK(werr)) {
		err = SBC_ERR_BADFILE;
		goto done;
	}

	err = ctx->ops->open_conf(ctx);
	if (!SBC_ERROR_IS_OK(err)) {
		DEBUG(1, ("Error opening the registry.\n"));
		goto done;
	}

	werr = reg_open_path(ctx, ctx->path,
			     KEY_ENUMERATE_SUB_KEYS | REG_KEY_WRITE,
			     token, &rpd(ctx)->base_key);
	if (!W_ERROR_IS_OK(werr)) {
		err = SBC_ERR_UNKNOWN_FAILURE;
		goto done;
	}

done:
	return err;
}
예제 #3
0
void ChildForm::runProcess()
{
    RunProcessDialog rpd(this);
    // If the process failed to start, then it
    // cannot be deleted from the processError call
    // because it may be called from within the call to
    // _proc->start()... so _proc cannot be deleted...
    if ((_proc != nullptr) && (_procError == true))
    {
        deleteProcess();
    }
    if (_proc == nullptr)
    {
        if (rpd.exec() == RunProcessDialog::Accepted)
        {
            _procError = false;
            _redirectStdout = rpd.isStdoutRedirected();
            _redirectStderr = rpd.isStderrRedirected();

            _proc = new QProcess(this);
            connect(_proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));
            connect(_proc, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr()));
            connect(_proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
            connect(_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this,
                    SLOT(processDone(int,QProcess::ExitStatus)));
            _proc->setWorkingDirectory(rpd.getWorkingDirectory());
            QStringList args = rpd.getArguments();
            suppressOutput(rpd.isOutputSuppressed());
            MainWindow::getMainWindow()->swapProcessIcon(true);
            _proc->start(rpd.getProgram(), args);
        }
    }
static sbcErr smbconf_reg_open(struct smbconf_ctx *ctx)
{
	WERROR werr;

	if (rpd(ctx)->open) {
		return SBC_ERR_OK;
	}

	werr = regdb_open();
	if (!W_ERROR_IS_OK(werr)) {
		return SBC_ERR_BADFILE;
	}

	rpd(ctx)->open = true;
	return SBC_ERR_OK;
}
/**
 * create a subkey of the base key (i.e. a service...)
 */
static sbcErr smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
					     struct smbconf_ctx *ctx,
					     const char * subkeyname,
					     struct registry_key **newkey)
{
	WERROR werr;
	sbcErr err = SBC_ERR_OK;
	TALLOC_CTX *create_ctx;
	enum winreg_CreateAction action = REG_ACTION_NONE;

	/* create a new talloc ctx for creation. it will hold
	 * the intermediate parent key (SMBCONF) for creation
	 * and will be destroyed when leaving this function... */
	create_ctx = talloc_stackframe();

	werr = reg_createkey(mem_ctx, rpd(ctx)->base_key, subkeyname,
			     REG_KEY_WRITE, newkey, &action);
	if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) {
		DEBUG(10, ("Key '%s' already exists.\n", subkeyname));
		err = SBC_ERR_FILE_EXISTS;
	}
	if (!W_ERROR_IS_OK(werr)) {
		DEBUG(5, ("Error creating key %s: %s\n",
			 subkeyname, win_errstr(werr)));
		err = SBC_ERR_UNKNOWN_FAILURE;
	}

	talloc_free(create_ctx);
	return err;
}
예제 #6
0
파일: io.c 프로젝트: vternal3/OSkernal
int rpd(int x){
    char c;
    if (x){
        c = table[x % BASE_10];
        rpd(x / BASE_10);
        putc(c);
    }
}
/**
 * delete a service from configuration
 */
static sbcErr smbconf_reg_delete_share(struct smbconf_ctx *ctx,
				       const char *servicename)
{
	WERROR werr;
	sbcErr err = SBC_ERR_OK;
	TALLOC_CTX *mem_ctx = talloc_stackframe();

	if (servicename != NULL) {
		werr = reg_deletekey_recursive(rpd(ctx)->base_key, servicename);
		if (!W_ERROR_IS_OK(werr)) {
			err = SBC_ERR_ACCESS_DENIED;
		}
	} else {
		err = smbconf_reg_delete_values(rpd(ctx)->base_key);
	}

	talloc_free(mem_ctx);
	return err;
}
/**
 * Open a subkey of the base key (i.e a service)
 */
static sbcErr smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
					   struct smbconf_ctx *ctx,
					   const char *servicename,
					   uint32 desired_access,
					   struct registry_key **key)
{
	WERROR werr;

	if (servicename == NULL) {
		*key = rpd(ctx)->base_key;
		return SBC_ERR_OK;
	}
	werr = reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename,
			   desired_access, key);
	if (W_ERROR_EQUAL(werr, WERR_BADFILE)) {
		return SBC_ERR_NO_SUCH_SERVICE;
	}
	if (!W_ERROR_IS_OK(werr)) {
		return SBC_ERR_NOMEM;
	}

	return SBC_ERR_OK;
}
예제 #9
0
파일: io.c 프로젝트: vternal3/OSkernal
int printd(int d){
    if(d<0) {putc('-');d = -d;}//take the absolute value of x
    
    if(d==0) putc('0');
    else rpd(d);
}
예제 #10
0
/**
 * get the list of share names defined in the configuration.
 * registry version.
 */
static sbcErr smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
					  TALLOC_CTX *mem_ctx,
					  uint32_t *num_shares,
					  char ***share_names)
{
	uint32_t count;
	uint32_t added_count = 0;
	TALLOC_CTX *tmp_ctx = NULL;
	WERROR werr;
	sbcErr err = SBC_ERR_OK;
	char *subkey_name = NULL;
	char **tmp_share_names = NULL;

	if ((num_shares == NULL) || (share_names == NULL)) {
		return SBC_ERR_INVALID_PARAM;
	}

	tmp_ctx = talloc_stackframe();

	/* if there are values in the base key, return NULL as share name */

	if (smbconf_reg_key_has_values(rpd(ctx)->base_key)) {
		err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
						   0, NULL);
		if (!SBC_ERROR_IS_OK(err)) {
			goto done;
		}
		added_count++;
	}

	/* make sure "global" is always listed first */
	if (smbconf_share_exists(ctx, GLOBAL_NAME)) {
		err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
						  added_count, GLOBAL_NAME);
		if (!SBC_ERROR_IS_OK(err)) {
			goto done;
		}
		added_count++;
	}

	for (count = 0;
	     werr = reg_enumkey(tmp_ctx, rpd(ctx)->base_key, count,
				&subkey_name, NULL),
	     W_ERROR_IS_OK(werr);
	     count++)
	{
		if (strequal(subkey_name, GLOBAL_NAME)) {
			continue;
		}

		err = smbconf_add_string_to_array(tmp_ctx,
						   &tmp_share_names,
						   added_count,
						   subkey_name);
		if (!SBC_ERROR_IS_OK(err)) {
			goto done;
		}
		added_count++;
	}
	if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
		err = SBC_ERR_NO_MORE_ITEMS;
		goto done;
	}
	err = SBC_ERR_OK;

	*num_shares = added_count;
	if (added_count > 0) {
		*share_names = talloc_move(mem_ctx, &tmp_share_names);
	} else {
		*share_names = NULL;
	}

done:
	talloc_free(tmp_ctx);
	return err;
}