/***************************************************************************
* CVSID: $Id$
*
* polkit-is-privileged.c : Determine if a user has privileges
*
* Copyright (C) 2006 David Zeuthen, <david@fubar.dk>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <libpolkit/libpolkit.h>
static void
{
"\n"
"usage : %s -u <uid> -p <privilege> [-r <resource>]\n"
" [-s <system-bus-connection-name>]", argv[0]);
"\n"
"Options:\n"
" -u, --user Username or user id\n"
" -s, --system-bus-unique-name Unique system bus connection name\n"
" -r, --resource Resource\n"
" -p, --privilege Privilege to test for\n"
" -h, --help Show this information and exit\n"
" -v, --verbose Verbose operation\n"
" -V, --version Print version number\n"
"\n"
"Queries system policy whether a given user is allowed for a given\n"
"privilege for a given resource. The resource may be omitted.\n"
"\n");
}
int
{
int rc;
};
rc = 1;
while (TRUE) {
int c;
if (c == -1)
break;
switch (c) {
case 's':
break;
case 'u':
break;
case 'r':
break;
case 'p':
break;
case 'v':
is_verbose = TRUE;
break;
case 'h':
rc = 0;
goto out;
case 'V':
rc = 0;
goto out;
default:
goto out;
}
}
return 1;
}
if (is_verbose) {
}
#ifdef POLKITD_ENABLED
dbus_error_init (&error);
if (connection == NULL) {
g_warning ("Cannot connect to system message bus");
return 1;
}
#endif /* POLKITD_ENABLED */
g_warning ("Cannot get libpolkit context");
goto out;
}
user,
NULL);
switch (result) {
case LIBPOLKIT_RESULT_OK:
break;
case LIBPOLKIT_RESULT_ERROR:
g_warning ("Error determing whether user is privileged.");
break;
g_print ("Invalid context.\n");
goto out;
g_print ("Not privileged.\n");
goto out;
goto out;
}
if (is_verbose) {
}
out:
return rc;
}