members-20080128/0000755000000000000000000000000012747220616010307 5ustar members-20080128/Makefile0000644000000000000000000000272107750724477011765 0ustar #this is the -*- makefile -*- for members. # # members is the complement of groups: whereas groups shows the groups a # specified user belongs to, members shows users belonging to a specified # group. # Copyright (c) 1997 by Jim Lynch. # This software comes with NO WARRANTY WHATSOEVER. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 dated June, 1991, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # On Debian Linux systems, the complete text of the GNU General # Public License can be found in `/usr/doc/copyright/GPL' (on some # installations) or /usr/share/common-licenses/GPL (on newer # ones). CPPFLAGS = -g -Wno-deprecated members: members.o g++ -o members members.o main.o: members.cc clean: rm -f members *.o *~ core install: members cp members $(DESTDIR)/usr/bin/members chmod 755 $(DESTDIR)/usr/bin/members chown bin.bin $(DESTDIR)/usr/bin/members members-20080128/debian/0000755000000000000000000000000012747221077011533 5ustar members-20080128/debian/changelog0000644000000000000000000000642312747221077013412 0ustar members (20080128-5+nmu1) unstable; urgency=medium * Non-maintainer upload. * Move from the no more supported debhelper compatibility level 4 to the currently recommended level 9 and make debian/rules and debian/control more future-proof: + Change "dh_clean -k" to "dh_prep". + Add now required targets build-indep and build-arch. + Add ${misc:Depends} to Depends + Closes: #817578 -- Axel Beckert Sat, 30 Jul 2016 23:54:22 +0200 members (20080128-5) unstable; urgency=low * #include #include (Closes: #504860) -- Lars Bahner Wed, 12 Nov 2008 20:54:44 +0100 members (20080128-4) unstable; urgency=low * Changed `pwd` to $(CURDIR) in rules. (Closes: #462947) -- Lars Bahner Mon, 28 Jan 2008 13:55:04 +0100 members (20080128-3) unstable; urgency=low * Bumped to newer version of debhelper. Cleaned packaging. -- Lars Bahner Mon, 28 Jan 2008 12:34:47 +0100 members (20080128-2) unstable; urgency=low * Cleaned up text in copyright and control file -- Lars Bahner Mon, 28 Jan 2008 12:15:33 +0100 members (20080128-1) unstable; urgency=low * Changed includes to be GCC-4.3 compatible. (Closes# 461684) * Removed useless file optparse.c from source -- Lars Bahner Mon, 28 Jan 2008 12:04:40 +0100 members (19990831-5) unstable; urgency=low * Compiled with GCC 4 -- Lars Bahner Sun, 19 Mar 2006 05:04:16 +0000 members (19990831-4) unstable; urgency=low * Typo with standards 3.6.1 corrected -- Lars Bahner Thu, 13 Nov 2003 02:11:08 +0100 members (19990831-3) unstable; urgency=low * Fixed dh_suidregister * Cleaned up in debian/rules * New standards version 3.6.1 * Compiling with -Wno-deprecated in lieu of a solution proper -- Lars Bahner Sat, 1 Nov 2003 13:24:08 +0100 members (19990831-2.3) unstable; urgency=low * New maintainer (closes: #202171) * lintian cleanup * Standards 3.6.0 -- Lars Bahner Mon, 28 Jul 2003 16:57:47 +0200 members (19990831-2.2) unstable; urgency=low * NMU * Add missing include of string.h to members.cc. (closes: Bug#114207) -- Doug Porter Fri, 19 Oct 2001 13:06:24 -0500 members (19990831-2.1) unstable; urgency=low * NMU * Add missing build-depends debhelper, fix gcc 3.0 issues. Closes: #104731. -- LaMont Jones Sat, 11 Aug 2001 17:13:32 -0600 members (19990831-2) unstable; urgency=low * maintainer address change. -- Jim Lynch Mon, 10 Jan 2000 02:56:29 -0800 members (19990831-1) unstable; urgency=low * Fixes Bug#43719. Problem was without default, did absolutely nothing including check for anything or setting any exit status. Now, when choosing no option, a default to -a is selected. -- Jim Lynch Tue, 31 Aug 1999 01:21:19 -0700 members (19990824-1) unstable; urgency=low * Added the ability to find primary and/or secondary members. -- Jim Lynch Tue, 23 Aug 1999 08:13:00 -0700 members (19980714-1) unstable; urgency=low * Initial Release. -- Jim Lynch Fri, 11 Jun 1999 15:49:02 -0700 Local variables: mode: debian-changelog End: members-20080128/debian/copyright0000644000000000000000000000216010747334367013472 0ustar This package was debianized by Jim Lynch on Fri, 11 Jun 1999 15:49:02 -0700. It was not downloaded. Upstream Author: Jim Lynch Copyright: # Copyright (c) 1997 by Jim Lynch. # This software comes with NO WARRANTY WHATSOEVER. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 dated June, 1991, 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 # Free Software Foundation, Inc. # 51 Franklin Street, Fifth floor # Boston, MA 02110-1301 # USA # # On Debian Linux systems, the complete text of the GNU General Public License # can be found in /usr/share/common-licenses/GPL (on newer ones). members-20080128/debian/compat0000644000000000000000000000000212744211005012714 0ustar 9 members-20080128/debian/substvars0000644000000000000000000000012510747336232013506 0ustar shlibs:Depends=libc6 (>= 2.3.6-6), libgcc1 (>= 1:4.1.1-12), libstdc++6 (>= 4.1.1-12) members-20080128/debian/dirs0000644000000000000000000000001010747335433012406 0ustar usr/bin members-20080128/debian/control0000644000000000000000000000144712744211273013136 0ustar Source: members Section: admin Priority: optional Maintainer: Lars Bahner Standards-Version: 3.7.3 Build-Depends: debhelper (>=9) Package: members Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Conflicts: suidmanager (<< 0.50) Description: Shows the members of a group; by default, all members members is the complement of groups: whereas groups shows the groups a specified user belongs to, members shows users belonging to a specified group. . Given the name of a group, members will send a space-separated list of member names to stdout. . Full option parsing has been added as of this version. You can ask for primary members, secondary members, both on one line, each on separate lines. If no option is selected, prints all members on one line by default. members-20080128/debian/manpages0000644000000000000000000000001210747337341013242 0ustar members.1 members-20080128/debian/README.Debian0000644000000000000000000000044606730750235013576 0ustar members for Debian ---------------------- The package is very, very simple (perhaps one of the simplest possible). The main part is the executable, called "members", installed into /usr/bin/members when you install the package. -- Jim Lynch , Fri, 11 Jun 1999 15:49:02 -0700 members-20080128/debian/rules0000755000000000000000000000177412747213164012622 0ustar #!/usr/bin/make -f #-*- makefile -*- # Made with the aid of dh_make, by Craig Small # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. # Some lines taken from debmake, by Christoph Lameter. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 build: build-arch build-indep build-arch: build-stamp build-indep: build-stamp build-stamp: dh_testdir $(MAKE) touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp install-stamp -$(MAKE) clean dh_clean install: install-stamp install-stamp: build-stamp dh_testdir dh_testroot dh_prep dh_installdirs $(MAKE) install DESTDIR=$(CURDIR)/debian/members touch install-stamp binary-indep: build install binary-arch: build install dh_testdir dh_testroot dh_installman dh_installdocs dh_installchangelogs dh_link dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary members-20080128/members.cc0000644000000000000000000002605311106632176012252 0ustar // members is the complement of groups: whereas groups shows the groups a // specified user belongs to, members shows users belonging to a specified // group. // PRESENTLY WORKING ON FULL OPTION PARSING (search for /**/ for work pt) // Copyright (c) 1997 by Jim Lynch. // This software comes with NO WARRANTY WHATSOEVER. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; version 2 dated June, 1991, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // On Debian Linux systems, the complete text of the GNU General // Public License can be found in `/usr/doc/copyright/GPL' (on some // installations) or /usr/share/common-licenses/GPL (on newer // ones). #include #include #include #include #include using std::cerr; using std::ostream; using std::endl; using std::cout; using std::hex; using std::endl; #include #include #include #include #define ALL_OPT 'a' #define PRIMARY_OPT 'p' #define SECONDARY_OPT 's' #define TWO_LINES_OPT 't' #define HELP_OPT 'h' #define END_SHORT_OPT '\0' #define END_LONG_OPT {(char *) 0, 0, (int *) 0, '\0'} const char short_blank = END_SHORT_OPT; const struct option long_blank = END_LONG_OPT; struct option longopts[] = { {"all", no_argument, (int *) 0, ALL_OPT }, {"primary", no_argument, (int *) 0, PRIMARY_OPT }, {"secondary", no_argument, (int *) 0, SECONDARY_OPT }, {"two-lines", no_argument, (int *) 0, TWO_LINES_OPT }, {"help", no_argument, (int *) 0, HELP_OPT }, END_LONG_OPT }; char opt_string[] = { ALL_OPT, PRIMARY_OPT, SECONDARY_OPT, TWO_LINES_OPT, HELP_OPT, END_SHORT_OPT }; int optionlen(struct option *option_array) { int result = 0; while(option_array[result].name != NULL) result++; return result; } void remove_short_option(char option, char *option_array) { int i; int found_index = -1; /* index of found index !or! -1 if none */ int size = strlen(option_array); for(i = 0; i < size; i++) { if(option_array[i] == option) { found_index = i; break; } } if(found_index != -1) { if(found_index != size - 1) /* not last item? */ { /* replace found item with last item */ option_array[found_index] = option_array[size - 1]; } /* blank out last item */ option_array[size - 1] = short_blank; } } void remove_long_option(char option, struct option *option_array) { int i; int found_index = -1; /* index of found index !or! -1 if none */ int size = optionlen(option_array); for(i = 0; i < size; i++) { if(option_array[i].val == option) { found_index = i; break; } } if(found_index != -1) { if(found_index != size - 1) /* not last item? */ { /* replace found item with last item */ option_array[found_index] = option_array[size - 1]; } /* blank out last item */ option_array[size - 1] = long_blank; } } void print_option_array(struct option *option_array) { int i = 0; while(option_array[i].val != short_blank) { if(option_array[i].flag != NULL) { cout << "{" << option_array[i].name << ", " << option_array[i].has_arg << ", " << (*option_array[i].flag) << ", '" << ( (char) option_array[i].val ) << "'=0x" << std::hex << option_array[i].val << "}" << std::dec << endl; } else { cout << "{" << option_array[i].name << ", " << option_array[i].has_arg << ", NULL, '" << ( (char) option_array[i].val ) << "'=0x" << std::hex << option_array[i].val << "}" << std::dec << endl; } i++; } } void disable_option(char *opt_chars) { while(*opt_chars) { remove_short_option(*opt_chars, opt_string); remove_long_option(*opt_chars, longopts); opt_chars++; } } void usage(ostream &out, char *name) { out << endl << "Usage: " << name; out << " [ -apst --all --primary --secondary --two-lines ] " << endl; } //receives: // - C string containing group name // - pointer to int containing (!assumed initialized!) flag // indicating whether a member name was printed on this line. // (if true, at least one member had been printed) // returns true if group found. int display_primaries(const char *groupString, int *printedOne) { int result = 0; struct group *theGroup; theGroup = getgrnam(groupString); if(theGroup) { struct passwd *thePasswd; setpwent(); thePasswd = getpwent(); if(thePasswd) { thePasswd = getpwent(); while(thePasswd) { if(thePasswd->pw_gid == theGroup->gr_gid) { // if there is at least one, print it without any space // if there is at least one more, print space then it if(*printedOne) cout << " "; else *printedOne = 1; cout << thePasswd->pw_name; } thePasswd = getpwent(); } } endpwent(); result = 1; } return result; } //receives: // - C string containing group name // - pointer to int containing (!assumed initialized!) flag // indicating whether a member name was printed on this line. // (if true, at least one member had been printed) // returns true if group found. int display_secondaries(const char *groupString, int *printedOne) { int result = 0; struct group *theGroup; theGroup = getgrnam(groupString); if(theGroup) { char **member = theGroup->gr_mem; result = 1; // if there is at least one, print it without any space // if there is at least one more, print space then it while(*member) { if(*printedOne) cout << " "; else *printedOne = 1; cout << *member++; } } return result; } int main(int argc, char *argv[]) { int result = 1; // pessimistic since we do something if success int first_nonopt = 1; /* index of the first non-option in argv */ int is_bad_opt = 0; /* true if unrecognized option */ int getopt_result; int longindex = 0; int wants_help = 0; /* boolean from options */ int wants_all_members = 0; int wants_primary = 0; int wants_secondary = 0; int wants_two_lines = 0; getopt_result = getopt_long ( argc, argv, opt_string, longopts, &longindex ); while(getopt_result != EOF) { /* process opts here */ switch(getopt_result) { case ALL_OPT: wants_all_members = 1; disable_option("apst"); break; case PRIMARY_OPT: wants_primary = 1; disable_option("apst"); break; case SECONDARY_OPT: wants_secondary = 1; disable_option("apst"); break; case TWO_LINES_OPT: wants_two_lines = 1; disable_option("apst"); break; case HELP_OPT: wants_help = 1; disable_option("apst"); break; case '?': default: is_bad_opt = 1; break; } if(is_bad_opt) break; else getopt_result = getopt_long ( argc, argv, opt_string, longopts, &longindex ); } first_nonopt = optind; #ifdef SKIP // display results of option parsing cout << "wants_help: " << ( wants_help ? "yes" : "no" ) << endl; cout << "wants_all_members: " << ( wants_all_members ? "yes" : "no" ) << endl; cout << "wants_primary: " << ( wants_primary ? "yes" : "no" ) << endl; cout << "wants_secondary: " << ( wants_secondary ? "yes" : "no" ) << endl; cout << "wants_two_lines: " << ( wants_two_lines ? "yes" : "no" ) << endl; cout << "argc: " << argc << "; first_nonopt: " << first_nonopt << endl; #endif if(wants_help) { usage(cout, argv[0]); cout << "You can use -one- of -a, -p, -s, or -t." << endl; cout << endl; cout << endl; cout << "OPTIONS" << endl; cout << endl; cout << " -a or --all" << endl; cout << " [default] show all members, both primary and secondary." << endl; cout << endl; cout << " -p or --primary" << endl; cout << " show only primary members" << endl; cout << " -s or --secondary" << endl; cout << " show only secondary members" << endl; cout << "" << endl; cout << " -t or --two-lines" << endl; cout << " output two lines, first is primary group members," << endl; cout << " secondary members on the second line." << endl; cout << "" << endl; cout << " -h or --help" << endl; cout << " print this message and exit successfully" << endl; cout << "" << endl; cout << "ARGUMENTS" << endl; cout << "" << endl; cout << " group (required)" << endl; cout << " the group to find members in." << endl; cout << "" << endl; cout << "SEE ALSO: man members for details." << endl; cout << "" << endl; return 0; } else if(argc != first_nonopt + 1) { usage(cerr, argv[0]); return 1; } if(argc == first_nonopt + 1) { int bad = 0; int sbad = 0; int printedOne; if // user wants default (i.e., no option selected)? ( ! ( wants_all_members || wants_primary || wants_secondary || wants_two_lines ) ) { wants_all_members = 1; // the default for this app } // fill in responses to errors if(wants_all_members) { printedOne = 0; if(display_primaries(argv[first_nonopt], &printedOne)) { if(display_secondaries(argv[first_nonopt], &printedOne)) if(printedOne) cout << endl; else sbad = 1; } else bad = 1; } else if(wants_primary) { printedOne = 0; bad = ! display_primaries(argv[first_nonopt], &printedOne); if(! bad) cout << endl; } else if(wants_secondary) { printedOne = 0; bad = ! display_secondaries(argv[first_nonopt], &printedOne); if( (! bad) && printedOne) cout << endl; } else if(wants_two_lines) { printedOne = 0; bad = ! display_primaries(argv[first_nonopt], &printedOne); if(! bad) { cout << endl; printedOne = 0; sbad = ! display_secondaries(argv[first_nonopt], &printedOne); cout << endl; } } if(bad) // presumably, group does not exist { cerr << "members: group " << argv[first_nonopt] << " does not exist"; cerr << endl; } result = bad || sbad; } else result = 1; return result; } members-20080128/members.10000644000000000000000000000325706763065457012045 0ustar .TH MEMBERS 1 .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection .\" other parms are allowed: see man(7), man(1) .SH NAME members \- outputs members of a group .SH SYNOPSIS .B members .I "groupname" .SH "DESCRIPTION" This manual page documents briefly the .BR members commands. This manual page was written for the Debian GNU/Linux distribution. .PP .B members is a program that sends a space-separated list of secondary member names to its standard output. .SH OPTIONS The programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. .\" For a complete description, see the Info files. .TP .B \-a, \-\-all Show all group members on one line. This is the default. .TP .B \-p, \-\-primary Show only primary group members. .TP .B \-s, \-\-secondary Show only secondary group members. .TP .B \-t, \-\-two-lines Send two lines to standard output. First line is primary members, second line is secondary members. NOTE: This always displays two lines, even if there are no members at all. .TP .B \-h, \-\-help Show summary of options. .\" .TP .\" .B \-v, \-\-version .\" Show version of program. .SH DIAGNOSTICS .PP Exit status is 0 (i.e. "success") if the group was found, and 1 (i.e., "failure") if the group was not found. .PP Technically, the exit status hinges on the output of .B getgrnam(3) as follows: if .B getgrnam(3) returns a null pointer, the exit status is 1, and 0 otherwise. .SH BUGS I don't know of any! If you find one, please let me know! .SH "SEE ALSO" groups(1) .SH AUTHOR This manual page was written by Jim Lynch , for the Debian GNU/Linux system (but may be used by others).