Back to index

lightdm  1.3.2
lightdm-guest-session-wrapper.c
Go to the documentation of this file.
00001 /* -*- Mode: C; indent-tabs-mode: nil; tab-width: 4 -*-
00002  *
00003  * Copyright (C) 2011 Canonical Ltd.
00004  * Author: Martin Pitt <martin.pitt@ubuntu.com>
00005  * 
00006  * This program is free software: you can redistribute it and/or modify it under
00007  * the terms of the GNU General Public License as published by the Free Software
00008  * Foundation, either version 3 of the License, or (at your option) any later
00009  * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
00010  * license.
00011  */
00012 
00013 /* This is a simple wrapper which just re-execve()'s the program given as its
00014  * arguments. This allows MAC systems like AppArmor or SELinux to apply a
00015  * policy on this wrapper which applies to guest sessions only. */
00016 
00017 #include <stdlib.h>
00018 #include <stdio.h>
00019 #include <string.h>
00020 #include <errno.h>
00021 #include <unistd.h>
00022 
00023 int
00024 main (int argc, char *argv[], char *envp[])
00025 {
00026     if (argc < 2)
00027     {
00028         fprintf (stderr, "Usage: %s COMMAND [ARGS]\n", argv[0]);
00029         return EXIT_FAILURE;
00030     }
00031 
00032     execve (argv[1], argv+1, envp);
00033 
00034     fprintf (stderr, "Failed to run guest session '%s': %s\n", argv[1], strerror (errno));
00035 
00036     return EXIT_FAILURE;
00037 }