/*
SSSD
IPA back end -- set SELinux context in a child module
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2014 Red Hat
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 <unistd.h>
#include <popt.h>
#include "util/child_common.h"
struct input_buffer {
const char *seuser;
const char *mls_range;
const char *username;
};
struct input_buffer *ibuf)
{
size_t p = 0;
/* seuser */
if (len == 0) {
"Empty SELinux user, will delete the mapping\n");
} else {
p += len;
}
/* MLS range */
if (len == 0) {
return EINVAL;
}
} else {
p += len;
}
/* username */
if (len == 0) {
return EINVAL;
} else {
p += len;
}
return EOK;
}
{
size_t p = 0;
/* A buffer with the following structure must be created:
* uint32_t status of the request (required)
*/
return ENOMEM;
}
/* result */
return EOK;
}
int result,
{
int ret;
if (r == NULL) {
return ENOMEM;
}
r->size = 0;
return ret;
}
*rsp = r;
return EOK;
}
const char *mls)
{
int ret;
/* This is a workaround for
* https://bugzilla.redhat.com/show_bug.cgi?id=1186422 to make sure
* the directories are created with the expected permissions
*/
/* An empty SELinux user should cause SSSD to use the system
* default. We need to remove the SELinux user from the DB
* in that case
*/
} else {
}
return ret;
}
{
bool needs_update = true;
"get_seuser: ret: %d seuser: %s mls: %s\n",
needs_update = false;
}
return needs_update;
}
{
int opt;
bool needs_update;
_("Debug level"), NULL},
_("Add debug timestamps"), NULL},
_("Show timestamps with microseconds"), NULL},
_("An open file descriptor for the debug logs"), NULL},
&debug_to_stderr, 0,
_("Send the debug output to stderr directly."), NULL },
};
/* Set debug level to invalid value so we can decide if -d 0 was used. */
switch(opt) {
default:
_exit(-1);
}
}
if (debug_prg_name == NULL) {
goto fail;
}
if (debug_fd != -1) {
}
}
/* libsemanage calls access(2) which works with real IDs, not effective.
* We need to switch also the real ID to 0.
*/
if (getuid() != 0) {
if (ret == -1) {
"setuid failed: %d, selinux_child might not work!\n", ret);
}
}
if (getgid() != 0) {
if (ret == -1) {
"setgid failed: %d, selinux_child might not work!\n", ret);
}
}
goto fail;
}
goto fail;
}
goto fail;
}
errno = 0;
if (len == -1) {
goto fail;
}
goto fail;
}
if (needs_update == true) {
goto fail;
}
}
goto fail;
}
errno = 0;
if (written == -1) {
goto fail;
}
goto fail;
}
return EXIT_SUCCESS;
fail:
return EXIT_FAILURE;
}