tools_util.c revision 3c60433641ce2e86b9b04778c8f8652ef0d097e4
/*
SSSD
Copyright (C) Jakub Hrozek <jhrozek@redhat.com> 2009
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <talloc.h>
#include <tevent.h>
#include <popt.h>
#include <errno.h>
#include <fcntl.h>
#include "config.h"
#include "tools/tools_util.h"
#include "tools/sss_sync_ops.h"
{
char *confdb_path;
int ret;
if (confdb_path == NULL) {
return ENOMEM;
}
/* Connect to the conf db */
return ret;
}
return ret;
}
return EOK;
}
/*
* Print poptUsage as well as our error message
*/
{
}
{
char **out;
char *orig, *n, *o;
char delim = ',';
unsigned int tokens = 1;
int i;
n = orig;
tokens = 1;
n++;
tokens++;
}
if (!out) {
return ENOMEM;
}
n = o = orig;
for (i = 0; i < tokens; i++) {
o = n;
if (!n) {
break;
}
*n = '\0';
n++;
}
return EOK;
}
char **groups)
{
int i;
int ret;
if (!groups) {
return EOK;
}
for (i = 0; groups[i]; ++i) {
continue;
}
/* If FQDN is specified, it must be within the same domain as user */
if (domain) {
return EINVAL;
}
/* Use only groupname */
talloc_zfree(groups[i]);
return ENOMEM;
}
}
}
return EOK;
}
const char *fullname)
{
int ret;
DEBUG(0, ("Cannot parse full name\n"));
return ret;
}
if (domain) {
/* only the local domain, whatever named is allowed in tools */
return EINVAL;
}
}
return EOK;
}
char **grouplist,
char **badgroup)
{
int ret;
int i;
if (!groupinfo) {
return ENOMEM;
}
for (i=0; grouplist[i]; ++i) {
grouplist[i],
if (ret) {
break;
}
}
return ret;
}
struct sss_domain_info *dom)
{
if (id &&
return ERANGE;
}
return EOK;
}
int set_locale(void)
{
char *c;
if (c == NULL) {
return EIO;
}
errno = 0;
if (c == NULL) {
return errno;
}
errno = 0;
c = textdomain(PACKAGE);
if (c == NULL) {
return errno;
}
return EOK;
}
{
int ret;
return ENOMEM;
}
/* Connect to the database */
goto fini;
}
goto fini;
}
ERROR("Out of memory\n");
goto fini;
}
fini:
return ret;
}
/*
* Check is path is owned by uid
* returns 0 - owns
* -1 - does not own
* >0 - an error occured, error code
*/
{
int ret;
if (ret != 0) {
return ret;
}
return EOK;
}
return -1;
}
const char *maildir,
const char *username,
bool force)
{
int ret;
char *spool_file;
if (spool_file == NULL) {
goto fail;
}
if (force == false) {
/* Check the owner of the mail spool */
switch (ret) {
case 0:
break;
case -1:
spool_file, uid));
/* FALLTHROUGH */
default:
goto fail;
}
}
if (ret != 0) {
goto fail;
}
fail:
return ret;
}
const char *homedir,
const char *maildir,
const char *username,
{
int ret;
/* Should this be fatal? I don't think so. Maybe convert to ERROR? */
}
return EPERM;
}
/* Remove the tree */
return ret;
}
return EOK;
}
/* The reason for not putting this into create_homedir
* is better granularity when it comes to reporting error
* messages and tracebacks in pysss
*/
const char *username,
const char *maildir,
{
char *spool_file = NULL;
int fd = -1;
int ret;
if (spool_file == NULL) {
goto fail;
}
if (fd < 0) {
goto fail;
}
if (ret != 0) {
goto fail;
}
if (ret != 0) {
goto fail;
}
if (ret != 0) {
}
fail:
if (fd >= 0) {
if (ret != 0) {
}
}
return ret;
}
int create_homedir(const char *skeldir,
const char *homedir,
{
int ret;
if (ret != 0) {
goto done;
}
if (ret != 0) {
goto done;
}
if (ret != 0) {
goto done;
}
goto done;
}
done:
return ret;
}
{
char *userdel_cmd = NULL;
if (!conf_path) {
goto done;
}
NULL, &userdel_cmd);
goto done;
}
errno = 0;
if (pid == 0) {
/* child */
} else {
/* parent */
if (pid == -1) {
goto done;
}
if (child_pid == -1) {
goto done;
}
if (ret != 0) {
userdel_cmd, ret));
goto done;
}
} else if (WIFSIGNALED(status)) {
goto done;
} else if (WIFSTOPPED(status)) {
continue;
} else {
goto done;
}
}
}
done:
return ret;
}