Skip to content

Commit

Permalink
Hide more netgroup-related stuff behind ifdefs
Browse files Browse the repository at this point in the history
Otherwise compiler complains about unused variables when building
without netgroup support (e.g. musl):

 ../src/polkitbackend/polkitbackendduktapeauthority.c: In function 'js_polkit_user_is_in_netgroup':
../src/polkitbackend/polkitbackendduktapeauthority.c:1184:15: error: variable 'netgroup' set but not used [-Werror=unused-but-set-variable]
 1184 |   const char *netgroup;
      |               ^~~~~~~~
../src/polkitbackend/polkitbackendduktapeauthority.c:1183:15: error: variable 'user' set but not used [-Werror=unused-but-set-variable]
 1183 |   const char *user;
      |               ^~~~
cc1: all warnings being treated as errors

 ../src/polkitbackend/polkitbackendinteractiveauthority.c: In function 'get_users_in_net_group':
../src/polkitbackend/polkitbackendinteractiveauthority.c:2279:16: error: unused variable 'name' [-Werror=unused-variable]
 2279 |   const gchar *name;
      |                ^~~~
cc1: all warnings being treated as errors

../src/polkit/polkitidentity.c: In function 'polkit_identity_new_for_gvariant':
../src/polkit/polkitidentity.c:349:19: error: unused variable 'name' [-Werror=unused-variable]
  349 |       const char *name;
      |                   ^~~~
../src/polkit/polkitidentity.c:348:17: error: unused variable 'v' [-Werror=unused-variable]
  348 |       GVariant *v;
      |                 ^
cc1: all warnings being treated as errors
  • Loading branch information
mrc0mmand authored and jrybar-rh committed Feb 6, 2025
1 parent ed17c96 commit e92e077
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
15 changes: 7 additions & 8 deletions src/polkit/polkitidentity.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,10 @@ polkit_identity_new_for_gvariant (GVariant *variant,
}
else if (g_strcmp0 (kind, "unix-netgroup") == 0)
{
#ifdef HAVE_SETNETGRENT
GVariant *v;
const char *name;

#ifndef HAVE_SETNETGRENT
g_set_error (error,
POLKIT_ERROR,
POLKIT_ERROR_FAILED,
"Netgroups are not available on this machine");
goto out;
#else

v = lookup_asv (details_gvariant, "name", G_VARIANT_TYPE_STRING, error);
if (v == NULL)
{
Expand All @@ -365,6 +358,12 @@ polkit_identity_new_for_gvariant (GVariant *variant,
name = g_variant_get_string (v, NULL);
ret = polkit_unix_netgroup_new (name);
g_variant_unref (v);
#else
g_set_error (error,
POLKIT_ERROR,
POLKIT_ERROR_FAILED,
"Netgroups are not available on this machine");
goto out;
#endif
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/polkitbackend/polkitbackendduktapeauthority.c
Original file line number Diff line number Diff line change
Expand Up @@ -1180,13 +1180,13 @@ js_polkit_spawn (duk_context *cx)
static duk_ret_t
js_polkit_user_is_in_netgroup (duk_context *cx)
{
gboolean is_in_netgroup = FALSE;
#ifdef HAVE_SETNETGRENT
const char *user;
const char *netgroup;
gboolean is_in_netgroup = FALSE;

user = duk_require_string (cx, 0);
netgroup = duk_require_string (cx, 1);
#ifdef HAVE_SETNETGRENT
if (innetgr (netgroup,
NULL, /* host */
user,
Expand Down
5 changes: 2 additions & 3 deletions src/polkitbackend/polkitbackendinteractiveauthority.c
Original file line number Diff line number Diff line change
Expand Up @@ -2276,11 +2276,10 @@ static GList *
get_users_in_net_group (PolkitIdentity *group,
gboolean include_root)
{
GList *ret = NULL;
#ifdef HAVE_SETNETGRENT
const gchar *name;
GList *ret;

ret = NULL;
#ifdef HAVE_SETNETGRENT
name = polkit_unix_netgroup_get_name (POLKIT_UNIX_NETGROUP (group));

# ifdef HAVE_SETNETGRENT_RETURN
Expand Down

0 comments on commit e92e077

Please sign in to comment.