Print this page
10136 smatch fix for policykit


   4  * polkit-is-privileged.c : Determine if a user has privileges
   5  *
   6  * Copyright (C) 2006 David Zeuthen, <david@fubar.dk>
   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 2 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, write to the Free Software
  20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  21  *
  22  **************************************************************************/
  23 



  24 
  25 #ifdef HAVE_CONFIG_H
  26 #  include <config.h>
  27 #endif
  28 
  29 #include <stdio.h>
  30 #include <stdlib.h>
  31 #include <getopt.h>
  32 #include <dbus/dbus.h>
  33 
  34 #include <libpolkit/libpolkit.h>
  35 
  36 static void
  37 usage (int argc, char *argv[])
  38 {
  39         fprintf (stderr, "polkit-is-privileged version " PACKAGE_VERSION "\n");
  40 
  41         fprintf (stderr, 
  42                  "\n" 
  43                  "usage : %s -u <uid> -p <privilege> [-r <resource>]\n" 


 182         case LIBPOLKIT_RESULT_NOT_PRIVILEGED:
 183                 g_print ("Not privileged.\n");
 184                 goto out;
 185 
 186         case LIBPOLKIT_RESULT_NO_SUCH_PRIVILEGE:
 187                 g_print ("No such privilege '%s'.\n", privilege);
 188                 goto out;
 189 
 190         case LIBPOLKIT_RESULT_NO_SUCH_USER:
 191                 g_print ("No such user '%s'.\n", user);
 192                 goto out;
 193         }
 194 
 195         if (is_verbose) {
 196                 printf ("result %d\n", result);
 197                 printf ("is_allowed %d\n", is_allowed);
 198         }
 199 
 200 out:
 201         if (ctx != NULL)
 202                 libpolkit_free_context (ctx);
 203 
 204         return rc;
 205 }
 206 


   4  * polkit-is-privileged.c : Determine if a user has privileges
   5  *
   6  * Copyright (C) 2006 David Zeuthen, <david@fubar.dk>
   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 2 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, write to the Free Software
  20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  21  *
  22  **************************************************************************/
  23 
  24 /*
  25  * Copyright (c) 2018, Joyent, Inc.
  26  */
  27 
  28 #ifdef HAVE_CONFIG_H
  29 #  include <config.h>
  30 #endif
  31 
  32 #include <stdio.h>
  33 #include <stdlib.h>
  34 #include <getopt.h>
  35 #include <dbus/dbus.h>
  36 
  37 #include <libpolkit/libpolkit.h>
  38 
  39 static void
  40 usage (int argc, char *argv[])
  41 {
  42         fprintf (stderr, "polkit-is-privileged version " PACKAGE_VERSION "\n");
  43 
  44         fprintf (stderr, 
  45                  "\n" 
  46                  "usage : %s -u <uid> -p <privilege> [-r <resource>]\n" 


 185         case LIBPOLKIT_RESULT_NOT_PRIVILEGED:
 186                 g_print ("Not privileged.\n");
 187                 goto out;
 188 
 189         case LIBPOLKIT_RESULT_NO_SUCH_PRIVILEGE:
 190                 g_print ("No such privilege '%s'.\n", privilege);
 191                 goto out;
 192 
 193         case LIBPOLKIT_RESULT_NO_SUCH_USER:
 194                 g_print ("No such user '%s'.\n", user);
 195                 goto out;
 196         }
 197 
 198         if (is_verbose) {
 199                 printf ("result %d\n", result);
 200                 printf ("is_allowed %d\n", is_allowed);
 201         }
 202 
 203 out:
 204         if (ctx != NULL)
 205                 (void) libpolkit_free_context (ctx);
 206 
 207         return rc;
 208 }
 209