~ubuntu-branches/ubuntu/saucy/sssd/saucy

« back to all changes in this revision

Viewing changes to server/tools/tools_util.h

  • Committer: Stéphane Graber
  • Date: 2011-06-15 16:23:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: stgraber@ubuntu.com-20110615162314-rbhoppnpaxfqo5q7
Merge 1.5.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Authors:
3
 
        Jakub Hrozek <jhrozek@redhat.com>
4
 
        Simo Sorce <ssorce@redhat.com>
5
 
 
6
 
    Copyright (C) 2009 Red Hat
7
 
 
8
 
    This program is free software; you can redistribute it and/or modify
9
 
    it under the terms of the GNU General Public License as published by
10
 
    the Free Software Foundation; either version 3 of the License, or
11
 
    (at your option) any later version.
12
 
 
13
 
    This program is distributed in the hope that it will be useful,
14
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
    GNU General Public License for more details.
17
 
 
18
 
    You should have received a copy of the GNU General Public License
19
 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 
*/
21
 
 
22
 
 
23
 
#ifndef __TOOLS_UTIL_H__
24
 
#define __TOOLS_UTIL_H__
25
 
 
26
 
#include <popt.h>
27
 
 
28
 
#include "util/util.h"
29
 
 
30
 
#define CHECK_ROOT(val, prg_name) do { \
31
 
    val = getuid(); \
32
 
    if (val != 0) { \
33
 
        DEBUG(1, ("Running under %d, must be root\n", val)); \
34
 
        ERROR("%s must be run as root\n", prg_name); \
35
 
        val = EXIT_FAILURE; \
36
 
        goto fini; \
37
 
    } \
38
 
} while(0)
39
 
 
40
 
struct tools_ctx {
41
 
    struct tevent_context *ev;
42
 
    struct confdb_ctx *confdb;
43
 
    struct sysdb_ctx *sysdb;
44
 
 
45
 
    struct sss_names_ctx *snctx;
46
 
    struct sss_domain_info *local;
47
 
 
48
 
    struct ops_ctx *octx;
49
 
 
50
 
    struct sysdb_handle *handle;
51
 
    bool transaction_done;
52
 
    int error;
53
 
};
54
 
 
55
 
int init_sss_tools(struct tools_ctx **_tctx);
56
 
 
57
 
void usage(poptContext pc, const char *error);
58
 
 
59
 
int set_locale(void);
60
 
 
61
 
 
62
 
int parse_name_domain(struct tools_ctx *tctx,
63
 
                      const char *fullname);
64
 
 
65
 
int id_in_range(uint32_t id,
66
 
                struct sss_domain_info *dom);
67
 
 
68
 
int parse_groups(TALLOC_CTX *mem_ctx,
69
 
                 const char *optstr,
70
 
                 char ***_out);
71
 
 
72
 
int parse_group_name_domain(struct tools_ctx *tctx,
73
 
                            char **groups);
74
 
 
75
 
int check_group_names(struct tools_ctx *tctx,
76
 
                      char **grouplist,
77
 
                      char **badgroup);
78
 
 
79
 
int create_homedir(TALLOC_CTX *mem_ctx,
80
 
                   const char *skeldir,
81
 
                   const char *homedir,
82
 
                   const char *username,
83
 
                   uid_t uid,
84
 
                   gid_t gid,
85
 
                   mode_t default_umask);
86
 
 
87
 
int create_mail_spool(TALLOC_CTX *mem_ctx,
88
 
                      const char *username,
89
 
                      const char *maildir,
90
 
                      uid_t uid, gid_t gid);
91
 
 
92
 
int remove_homedir(TALLOC_CTX *mem_ctx,
93
 
                   const char *homedir,
94
 
                   const char *maildir,
95
 
                   const char *username,
96
 
                   uid_t uid, bool force);
97
 
 
98
 
/* from files.c */
99
 
int remove_tree(const char *root);
100
 
 
101
 
int copy_tree(const char *src_root,
102
 
              const char *dst_root,
103
 
              uid_t uid, gid_t gid);
104
 
 
105
 
int selinux_file_context(const char *dst_name);
106
 
int reset_selinux_file_context(void);
107
 
 
108
 
#endif  /* __TOOLS_UTIL_H__ */