Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions lib/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,33 @@
#endif


#if (__GNUC__ >= 10)
# define MAYBE_UNUSED [[gnu::unused]]
# define NORETURN [[gnu::__noreturn__]]
# define format_attr(type, fmt, va) [[gnu::format(type, fmt, va)]]
# define ATTR_ACCESS(...) [[gnu::access(__VA_ARGS__)]]
# define ATTR_ALLOC_SIZE(...) [[gnu::alloc_size(__VA_ARGS__)]]
#if __has_c_attribute(maybe_unused)
# define MAYBE_UNUSED [[maybe_unused]]
#else
# define MAYBE_UNUSED
#endif

#if __has_c_attribute(noreturn)
# define NORETURN [[noreturn]]
#else
# define NORETURN
#endif

#if __has_c_attribute(gnu::format)
# define format_attr(type, fmt, va) [[gnu::format(type, fmt, va)]]
#else
# define format_attr(type, fmt, va)
#endif

#if __has_c_attribute(gnu::access)
# define ATTR_ACCESS(...) [[gnu::access(__VA_ARGS__)]]
#else
# define ATTR_ACCESS(...)
#endif

#if __has_c_attribute(gnu::alloc_size)
# define ATTR_ALLOC_SIZE(...) [[gnu::alloc_size(__VA_ARGS__)]]
#else
# define ATTR_ALLOC_SIZE(...)
#endif

Expand All @@ -30,7 +46,7 @@
# define ATTR_MALLOC(deallocator)
#endif

#if (__GNUC__ >= 14)
#if __has_c_attribute(gnu::null_terminated_string_arg)
# define ATTR_STRING(i) [[gnu::null_terminated_string_arg(i)]]
#else
# define ATTR_STRING(i)
Expand Down
20 changes: 13 additions & 7 deletions src/get_subid_owners.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stdio.h>

#include "atoi/getnum.h"
#include "attr.h"
#include "prototypes.h"
#include "shadowlog.h"
#include "stdlib.h"
Expand All @@ -14,13 +15,8 @@
static const char Prog[] = "get_subid_owners";


static void usage(void)
{
fprintf(stderr, "Usage: [-g] %s subuid\n", Prog);
fprintf(stderr, " list uids who own the given subuid\n");
fprintf(stderr, " pass -g to query a subgid\n");
exit(EXIT_FAILURE);
}
NORETURN static void usage(void);


int main(int argc, char *argv[])
{
Expand Down Expand Up @@ -52,3 +48,13 @@ int main(int argc, char *argv[])
free(uids);
return 0;
}


static void
usage(void)
{
fprintf(stderr, "Usage: [-g] %s subuid\n", Prog);
fprintf(stderr, " list uids who own the given subuid\n");
fprintf(stderr, " pass -g to query a subgid\n");
exit(EXIT_FAILURE);
}
21 changes: 14 additions & 7 deletions src/getsubids.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
#include <stdlib.h>
#include <string.h>

#include "attr.h"
#include "prototypes.h"
#include "shadowlog.h"
#include "string/strcmp/streq.h"
#include "subid.h"

static const char Prog[] = "getsubids";

static void usage(void)
{
fprintf(stderr, "Usage: %s [-g] user\n", Prog);
fprintf(stderr, " list subuid ranges for user\n");
fprintf(stderr, " pass -g to list subgid ranges\n");
exit(EXIT_FAILURE);
}

NORETURN static void usage(void);


int main(int argc, char *argv[])
{
Expand Down Expand Up @@ -49,3 +46,13 @@ int main(int argc, char *argv[])
subid_free(ranges);
return 0;
}


static void
usage(void)
{
fprintf(stderr, "Usage: %s [-g] user\n", Prog);
fprintf(stderr, " list subuid ranges for user\n");
fprintf(stderr, " pass -g to list subgid ranges\n");
exit(EXIT_FAILURE);
}
Loading