[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Cvs-cvs] ccvs/src ChangeLog admin.c sanity.sh subr.c sub...
From: |
Derek Robert Price |
Subject: |
[Cvs-cvs] ccvs/src ChangeLog admin.c sanity.sh subr.c sub... |
Date: |
Tue, 16 May 2006 01:30:35 +0000 |
CVSROOT: /cvsroot/cvs
Module name: ccvs
Branch:
Changes by: Derek Robert Price <address@hidden> 06/05/16 01:30:35
Modified files:
src : ChangeLog admin.c sanity.sh subr.c subr.h
watch.c watch.h
Log message:
* admin.c (admin): Factor CVS_ADMIN_GROUP check to...
* subr.c (is_admin): ...this new function.
* subr.h (is_admin): Add proto/macro.
* watch.c (watch_usage): Reformat and add -e/-u info.
(watch_modify_watchers): Accept <user>.
(watch_addremove): Process new args.
(addremove_args): Add user.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/ChangeLog.diff?tr1=1.3406&tr2=1.3407&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/admin.c.diff?tr1=1.113&tr2=1.114&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/sanity.sh.diff?tr1=1.1136&tr2=1.1137&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/subr.c.diff?tr1=1.149&tr2=1.150&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/subr.h.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/watch.c.diff?tr1=1.46&tr2=1.47&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/watch.h.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
Patches:
Index: ccvs/src/ChangeLog
diff -u ccvs/src/ChangeLog:1.3406 ccvs/src/ChangeLog:1.3407
--- ccvs/src/ChangeLog:1.3406 Sat May 13 00:54:04 2006
+++ ccvs/src/ChangeLog Tue May 16 01:30:34 2006
@@ -1,3 +1,13 @@
+2006-05-16 Derek Price <address@hidden>
+
+ * admin.c (admin): Factor CVS_ADMIN_GROUP check to...
+ * subr.c (is_admin): ...this new function.
+ * subr.h (is_admin): Add proto/macro.
+ * watch.c (watch_usage): Reformat and add -e/-u info.
+ (watch_modify_watchers): Accept <user>.
+ (watch_addremove): Process new args.
+ (addremove_args): Add user.
+
2006-05-12 Mark D. Baushke <address@hidden>
* log.c (log_expand_revlist): Add assert (r->first). It should
Index: ccvs/src/admin.c
diff -u ccvs/src/admin.c:1.113 ccvs/src/admin.c:1.114
--- ccvs/src/admin.c:1.113 Mon Apr 24 18:50:25 2006
+++ ccvs/src/admin.c Tue May 16 01:30:34 2006
@@ -18,11 +18,6 @@
# include <config.h>
#endif
-/* ANSI C headers. */
-#ifdef CVS_ADMIN_GROUP
-# include <grp.h>
-#endif
-
/* CVS headers. */
#include "ignore.h"
#include "recurse.h"
@@ -341,10 +336,6 @@
admin (int argc, char **argv)
{
int err;
-#ifdef CVS_ADMIN_GROUP
- struct group *grp;
- struct group *getgrnam (const char *);
-#endif
struct admin_data admin_data;
int c;
int i;
@@ -577,7 +568,6 @@
argc -= optind;
argv += optind;
-#ifdef CVS_ADMIN_GROUP
/* The use of `cvs admin -k' is unrestricted. However, any other
option is restricted if the group CVS_ADMIN_GROUP exists on the
server. */
@@ -587,39 +577,9 @@
* (server_active) rather than when not on the client.
*/
if (!current_parsed_root->isremote && !only_allowed_options &&
- (grp = getgrnam(CVS_ADMIN_GROUP)) != NULL)
- {
-#ifdef HAVE_GETGROUPS
- gid_t *grps;
- int n;
-
- /* get number of auxiliary groups */
- n = getgroups (0, NULL);
- if (n < 0)
- error (1, errno, "unable to get number of auxiliary groups");
- grps = xnmalloc (n + 1, sizeof *grps);
- n = getgroups (n, grps);
- if (n < 0)
- error (1, errno, "unable to get list of auxiliary groups");
- grps[n] = getgid ();
- for (i = 0; i <= n; i++)
- if (grps[i] == grp->gr_gid) break;
- free (grps);
- if (i > n)
- error (1, 0, "usage is restricted to members of the group `%s'",
- CVS_ADMIN_GROUP);
-#else
- char *me = getcaller ();
- char **grnam;
-
- for (grnam = grp->gr_mem; *grnam; grnam++)
- if (strcmp (*grnam, me) == 0) break;
- if (!*grnam && getgid () != grp->gr_gid)
- error (1, 0, "usage is restricted to members of the group %s",
- CVS_ADMIN_GROUP);
-#endif
- }
-#endif /* defined CVS_ADMIN_GROUP */
+ !is_admin ())
+ error (1, 0, "usage is restricted to members of the group %s",
+ CVS_ADMIN_GROUP);
for (i = 0; i < admin_data.ac; ++i)
{
Index: ccvs/src/sanity.sh
diff -u ccvs/src/sanity.sh:1.1136 ccvs/src/sanity.sh:1.1137
--- ccvs/src/sanity.sh:1.1136 Mon May 1 20:38:28 2006
+++ ccvs/src/sanity.sh Tue May 16 01:30:34 2006
@@ -23167,6 +23167,72 @@
+ rcs6)
+ # Test that CVS notices a specific type of corruption in the RCS
+ # archive. In the past, this type of corruption had turned up after
+ # a user ineptly attempted to delete a revision from an arcvhive
+ # manually.
+ mkdir rcs6; cd rcs6
+
+ # Make the project.
+ dotest rcs6-init-1 "$testcvs -Q co -ld top .; cd top"
+ mkdir rcs6
+ dotest rcs6-init-2 "$testcvs -Q add rcs6"
+ cd rcs6
+
+ # Populate it.
+ echo some words >afile
+ dotest rcs6-init-3 "$testcvs -Q add afile"
+ dotest rcs6-init-4 "$testcvs -Q ci -mnewfile afile" \
+"RCS file: $CVSROOT_DIRNAME/rcs6/afile,v
+done
+Checking in afile;
+$CVSROOT_DIRNAME/rcs6/afile,v <-- afile
+initial revision: 1\.1
+done"
+ echo more words >>afile
+ dotest rcs6-init-5 "$testcvs -Q ci -mrev2 afile" \
+"Checking in afile;
+$CVSROOT_DIRNAME/rcs6/afile,v <-- afile
+new revision: 1\.2; previous revision: 1\.1
+done"
+
+ # Corrupt the archive.
+ sed -e '8,12d' \
+ -e 's/^head 1\.2/head 1.1/' \
+ <$CVSROOT_DIRNAME/rcs6/afile,v \
+ >$CVSROOT_DIRNAME/rcs6/cfile,v
+
+ # These worked.
+ dotest rcs6-1 "$testcvs -q up" \
+"U cfile"
+ dotest rcs6-2 "$testcvs -q tag current" \
+"T afile
+T cfile"
+
+ # This hosed the archive further without any warnings.
+ echo even more words >>cfile
+ dotest rcs6-3 "$testcvs ci -mhose-it cfile" \
+"Checking in cfile;
+$CVSROOT_DIRNAME/rcs6/cfile,v <-- cfile
+new revision: 1\.2; previous revision: 1\.1
+done"
+
+ # This finally reports the corruption.
+ dotest rcs6-4 "$testcvs -q tag -F current"
+
+ if $keep; then
+ echo Keeping $TESTDIR and exiting due to --keep
+ exit 0
+ fi
+
+ cd ../../..
+ rm -r rcs6
+ rm -rf $CVSROOT_DIRNAME/rcs6
+ ;;
+
+
+
lockfiles)
# Tests of CVS lock files.
# TODO-maybe: Add a test where we arrange for a loginfo
Index: ccvs/src/subr.c
diff -u ccvs/src/subr.c:1.149 ccvs/src/subr.c:1.150
--- ccvs/src/subr.c:1.149 Mon Apr 24 18:50:27 2006
+++ ccvs/src/subr.c Tue May 16 01:30:35 2006
@@ -20,6 +20,11 @@
/* Verify interface. */
#include "subr.h"
+/* ANSI headers. */
+#ifdef HAVE_CVS_ADMIN_GROUP
+# include <grp.h>
+#endif
+
/* GNULIB headers. */
#include "canonicalize.h"
#include "canon-host.h"
@@ -2083,3 +2088,66 @@
free (p2);
return same;
}
+
+
+
+#ifdef HAVE_CVS_ADMIN_GROUP
+/* Return true if the current user should be allowed to run CVS admin commands,
+ * false otherwise.
+ */
+bool
+is_admin (void)
+{
+ struct group *grp;
+ struct group *getgrnam();
+
+ /* If the CVS_ADMIN_GROUP doesn't exist, assume that all users may run
+ * CVS admin commands.
+ */
+ errno = 0;
+ if (!(grp = getgrnam (CVS_ADMIN_GROUP)))
+ {
+ if (errno)
+ error (1, errno, "Failed to get group information for %s.",
+ CVS_ADMIN_GROUP);
+ return true;
+ }
+
+# ifdef HAVE_GETGROUPS
+ {
+ gid_t *grps;
+ int n, i;
+ size_t size;
+
+ /* get number of auxiliary groups */
+ n = getgroups (0, NULL);
+ if (n < 0)
+ error (1, errno, "unable to get number of auxiliary groups");
+ size = xtimes (xsum (n, 1), sizeof *grps);
+ grps = size_in_bounds_p (size) ? xmalloc (size) : NULL;
+ if (!grps) error (1, EOVERFLOW, "too many groups");
+ n = getgroups (n, grps);
+ if (n < 0)
+ error (1, errno, "unable to get list of auxiliary groups");
+ grps[n] = getgid();
+ for (i = 0; i <= n; i++)
+ if (grps[i] == grp->gr_gid) break;
+ free (grps);
+ if (i > n)
+ return false;
+ }
+# else /* !HAVE_GETGROUPS */
+ {
+ char *me = getcaller();
+ char **grnam;
+
+ for (grnam = grp->gr_mem; *grnam; grnam++)
+ if (strcmp (*grnam, me) == 0) break;
+ if (!*grnam && getgid() != grp->gr_gid)
+ return false;
+ }
+# endif /* HAVE_GETGROUPS */
+
+ return true;
+}
+#endif /* HAVE_CVS_ADMIN_GROUP */
Index: ccvs/src/subr.h
diff -u ccvs/src/subr.h:1.8 ccvs/src/subr.h:1.9
--- ccvs/src/subr.h:1.8 Mon Apr 24 18:50:27 2006
+++ ccvs/src/subr.h Tue May 16 01:30:35 2006
@@ -107,4 +107,14 @@
char *xcanonicalize_file_name (const char *path);
bool isThisHost (const char *otherhost);
bool isSamePath (const char *path1_in, const char *path2_in);
+
+# ifdef HAVE_CVS_ADMIN_GROUP
+bool is_admin (void);
+# else
+/* If the CVS_ADMIN_GROUP is not being used, then anyone may run admin
+ * commands.
+ */
+# define is_admin() true;
+# endif
+
#endif /* !SUBR_H */
Index: ccvs/src/watch.c
diff -u ccvs/src/watch.c:1.46 ccvs/src/watch.c:1.47
--- ccvs/src/watch.c:1.46 Mon Apr 24 18:50:27 2006
+++ ccvs/src/watch.c Tue May 16 01:30:35 2006
@@ -33,13 +33,18 @@
const char *const watch_usage[] =
{
- "Usage: %s %s {on|off|add|remove} [-lR] [-a <action>]... [<path>]...\n",
- "on/off: Turn on/off read-only checkouts of files.\n",
- "add/remove: Add or remove notification on actions.\n",
- "-l (on/off/add/remove): Local directory only, not recursive.\n",
- "-R (on/off/add/remove): Process directories recursively (default).\n",
- "-a (add/remove): Specify what actions, one of: `edit', `unedit',\n",
- " `commit', `all', or `none' (defaults to `all').\n",
+ "Usage: %s %s {on|off|add|remove} [-lR] [-a action]... [-u user]\n",
+ " [<path>]...\n",
+ "on/off\t\tTurn on/off read-only checkouts of files.\n",
+ "add/remove\tAdd or remove notification on actions.\n",
+ "\t-l\tLocal directory only, not recursive (on/off/add/remove).\n",
+ "\t-R\tProcess directories recursively (default, on/off/add/remove).\n",
+ "\t-a action\n",
+ "\t\tSpecify what actions, one of: `edit', `unedit', `commit',\n",
+ "\t\t`all', or `none' (defaults to `all', add/remove).\n",
+ "\t-e\tWith remove, remove temporary watches (aquired via `cvs edit')\n",
+ "\t-u user\tApply selection to user's watches (defaults to current\n",
+ "\t\tuser, only cvs administrators may affect other users, add/remove)\n",
"(Specify the --help global option for a list of other help options.)\n",
NULL
};
@@ -53,7 +58,7 @@
char *p;
char *pend;
char *nextp;
- char *who;
+ const char *who;
int who_len;
char *mycurattr;
char *mynewattr;
@@ -71,7 +76,14 @@
TRACE( TRACE_FUNCTION, "modify_watchers ( %s )", file );
- who = getcaller ();
+ if (the_args.user && strcmp (getcaller (), the_args.user) && !is_admin ())
+ {
+ error (1, 0,
+ "Editing other user's watches is restricted to the %s group.",
+ CVS_ADMIN_GROUP);
+ }
+
+ who = the_args.user ? the_args.user : getcaller ();
who_len = strlen (who);
/* Look for current watcher types for this user. */
@@ -279,9 +291,10 @@
the_args.num_dirs = 0;
the_args.dirs = NULL;
the_args.local = 0;
+ the_args.user = NULL;
optind = 0;
- while ((c = getopt (argc, argv, "+lRa:")) != -1)
+ while ((c = getopt (argc, argv, "+lRa:eu:")) != -1)
{
switch (c)
{
@@ -314,6 +327,18 @@
else
usage (watch_usage);
break;
+ case 'e':
+ if (the_args.adding)
+ {
+ error (0, 0, "-e is only valid with remove.");
+ usage (watch_usage);
+ }
+ the_args.remove_temp = 1;
+ break;
+ case 'u':
+ if (the_args.user) free ((char *)the_args.user);
+ the_args.user = xstrdup (optarg);
+ break;
case '?':
default:
usage (watch_usage);
@@ -367,6 +392,10 @@
option_with_arg ("-a", "commit");
if (!the_args.edit && !the_args.unedit && !the_args.commit)
option_with_arg ("-a", "none");
+ if (the_args.remove_temp)
+ send_arg ("-e");
+ if (the_args.user)
+ option_with_arg ("-u", the_args.user);
send_arg ("--");
send_files (argc, argv, the_args.local, 0, SEND_NO_CONTENTS);
send_file_names (argc, argv, SEND_EXPAND_WILD);
Index: ccvs/src/watch.h
diff -u ccvs/src/watch.h:1.8 ccvs/src/watch.h:1.9
--- ccvs/src/watch.h:1.8 Thu Aug 4 01:04:34 2005
+++ ccvs/src/watch.h Tue May 16 01:30:35 2006
@@ -21,6 +21,7 @@
int edit;
int unedit;
int commit;
+ const char *user;
/* Are we adding or removing (non-temporary) edit,unedit,and/or commit
watches? */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Cvs-cvs] ccvs/src ChangeLog admin.c sanity.sh subr.c sub...,
Derek Robert Price <=