Bläddra i källkod

Merge branch 'stable'

Conflicts:

	ChangeLog
	configure.ac
	debian/changelog
Guillem Jover 18 år sedan
förälder
incheckning
23857e8a44
7 ändrade filer med 111 tillägg och 83 borttagningar
  1. 37 0
      ChangeLog
  2. 19 0
      debian/changelog
  3. 3 0
      man/dpkg-genchanges.1
  4. 3 4
      scripts/dpkg-genchanges.pl
  5. 1 2
      scripts/dpkg-gencontrol.pl
  6. 1 1
      scripts/dpkg-source.pl
  7. 47 76
      utils/start-stop-daemon.c

+ 37 - 0
ChangeLog

@@ -66,6 +66,43 @@
 
 	* configure.ac: Bump version to 1.14.17~.
 
+2008-01-22  Guillem Jover  <guillem@debian.org>
+
+	* configure.ac: Release 1.14.16.3.
+
+2008-01-22  Guillem Jover  <guillem@debian.org>
+
+	* utils/start-stop-daemon.c (tvselector): Remove typedef.
+	(tvselector_sec): Remove function.
+	(tvselector_usec): Likewise.
+	(TVCALC_ELEM): Remove macro.
+	(TVCALC): Likewise.
+	(tsub): New function.
+	(tmul): Likewise.
+	(run_stop_schedule): Use tsub and tmul instead of TVCALC. Make sure
+	the time is not negative.
+
+2008-01-22  Guillem Jover  <guillem@debian.org>
+
+	* utils/start-stop-daemon.c (main): Only call initgroups if changeuser
+	is not NULL.
+
+2008-01-22  Guillem Jover  <guillem@debian.org>
+
+	* utils/start-stop-daemon.c (gid_in_current_groups): Remove function.
+	(main): Call initgroups if the real user or group are different than
+	the ones we should switch to. Call setgid before initgroups.
+
+2008-01-22  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/dpkg-genchanges.pl, scripts/dpkg-gencontrol.pl,
+	scripts/dpkg-source.pl: Remove the IO-layer that converts to
+	UTF-8. It's not as smart as I expected.
+
+	* scripts/dpkg-genchanges.pl: Do not substitute variables on
+	the output.
+	* man/dpkg-genchanges.pl: Document this change.
+
 2008-01-22  Guillem Jover  <guillem@debian.org>
 
 	* configure.ac: Release 1.14.16.2.

+ 19 - 0
debian/changelog

@@ -16,6 +16,25 @@ dpkg (1.14.17) UNRELEASED; urgency=low
 
  -- Guillem Jover <guillem@debian.org>  Mon, 21 Jan 2008 10:11:55 +0200
 
+dpkg (1.14.16.3) unstable; urgency=low
+
+  [ Raphael Hertzog ]
+  * Remove the ":utf8" layer that utf8-encodes already valid utf8.
+    Closes: #462098
+  * Disable variable substitution in dpkg-genchanges. Closes: #462079, #462089
+
+  [ Guillem Jover ]
+  * Make start-stop-daemon set the supplementary groups if the real user or
+    group are different than the ones we should switch to. Closes: #462075
+  * Fix segfault in start-stop-daemon when using --group w/o --chuid (as
+    a side effect, using --group alone works for the first time in years).
+    Closes: #462072
+  * Fix timeout computations for start-stop-daemon --retry option. This has
+    not worked properly for a long time (maybe never), but came to light
+    due to #460903's fix. Closes: #462104
+
+ -- Guillem Jover <guillem@debian.org>  Tue, 22 Jan 2008 23:39:59 +0200
+
 dpkg (1.14.16.2) unstable; urgency=low
 
   * Change uid after changing gid and initializing supplementary groups in

+ 3 - 0
man/dpkg-genchanges.1

@@ -79,6 +79,9 @@ Read substitution variables in
 .IR substvarsfile ;
 the default is
 .BR debian/substvars .
+No variable substitution is done on any of the fields that are output,
+however the special variable \fIFormat\fR will override the field of the
+same name.
 .TP
 .BI \-D field = value
 Override or add an output control file field.

+ 3 - 4
scripts/dpkg-genchanges.pl

@@ -200,6 +200,7 @@ $bad_parser = 1 if ($@);
 my $control = Dpkg::Control->new($controlfile);
 my $fields = Dpkg::Fields::Object->new();
 $substvars->set_version_substvars($changelog->{"Version"});
+$substvars->parse($varlistfile) if -e $varlistfile;
 
 if (not is_sourceonly) {
     open(FL,"<",$fileslistfile) || &syserr(_g("cannot read files list file"));
@@ -441,7 +442,7 @@ if (!is_binaryonly) {
 print(STDERR "$progname: $origsrcmsg\n") ||
     &syserr(_g("write original source message")) unless $quiet;
 
-$fields->{'Format'} = '${Format}'; # Use value stored in substvars
+$fields->{'Format'} = $substvars->get("Format");
 
 if (!defined($fields->{'Date'})) {
     chomp(my $date822 = `date -R`);
@@ -510,8 +511,6 @@ for my $f (keys %remove) {
     delete $fields->{$f};
 }
 
-binmode(STDOUT, ":utf8");
-$substvars->parse($varlistfile) if -e $varlistfile;
 tied(%{$fields})->set_field_importance(@changes_fields);
-tied(%{$fields})->output(\*STDOUT, $substvars);
+tied(%{$fields})->output(\*STDOUT); # Note: no substitution of variables
 

+ 1 - 2
scripts/dpkg-gencontrol.pl

@@ -348,11 +348,10 @@ my $fh_output;
 if (!$stdout) {
     $cf= "$packagebuilddir/DEBIAN/control";
     $cf= "./$cf" if $cf =~ m/^\s/;
-    open($fh_output, ">:utf8", "$cf.new") ||
+    open($fh_output, ">", "$cf.new") ||
         syserr(_g("cannot open new output control file \`%s'"), "$cf.new");
 } else {
     $fh_output = \*STDOUT;
-    binmode(STDOUT, ":utf8");
 }
 
 tied(%{$fields})->set_field_importance(@control_fields);

+ 1 - 1
scripts/dpkg-source.pl

@@ -768,7 +768,7 @@ if ($opmode eq 'build') {
     printf(_g("%s: building %s in %s")."\n",
            $progname, $sourcepackage, "$basenamerev.dsc")
         || &syserr(_g("write building message"));
-    open(DSC, ">:utf8", "$basenamerev.dsc") ||
+    open(DSC, ">", "$basenamerev.dsc") ||
         syserr(_g("create %s"), "$basenamerev.dsc");
 
     $substvars->parse($varlistfile) if $varlistfile && -e $varlistfile;

+ 47 - 76
utils/start-stop-daemon.c

@@ -185,48 +185,6 @@ static void fatal(const char *format, ...)
 static void badusage(const char *msg)
 	NONRETURNING;
 
-/* This next part serves only to construct the TVCALC macro, which
- * is used for doing arithmetic on struct timeval's.  It works like this:
- *   TVCALC(result, expression);
- * where result is a struct timeval (and must be an lvalue) and
- * expression is the single expression for both components.  In this
- * expression you can use the special values TVELEM, which when fed a
- * const struct timeval* gives you the relevant component, and
- * TVADJUST.  TVADJUST is necessary when subtracting timevals, to make
- * it easier to renormalise.  Whenver you subtract timeval elements,
- * you must make sure that TVADJUST is added to the result of the
- * subtraction (before any resulting multiplication or what have you).
- * TVELEM must be linear in TVADJUST.
- */
-typedef long tvselector(const struct timeval*);
-
-static long
-tvselector_sec(const struct timeval *tv)
-{
-	return tv->tv_sec;
-}
-
-static long
-tvselector_usec(const struct timeval *tv)
-{
-	return tv->tv_usec;
-}
-
-#define TVCALC_ELEM(result, expr, sec, adj)                           \
-{								      \
-  const long TVADJUST = adj;					      \
-  long (*const TVELEM)(const struct timeval *) = tvselector_##sec;    \
-  (result).tv_##sec = (expr);					      \
-}
-#define TVCALC(result, expr)					      \
-do {								      \
-  TVCALC_ELEM(result, expr, sec, (-1));				      \
-  TVCALC_ELEM(result, expr, usec, (+1000000));			      \
-  (result).tv_sec += (result).tv_usec / 1000000;		      \
-  (result).tv_usec %= 1000000;					      \
-} while (0)
-
-
 static void
 fatal(const char *format, ...)
 {
@@ -257,6 +215,29 @@ xgettimeofday(struct timeval *tv)
 	if (gettimeofday(tv, NULL) != 0)
 		fatal("gettimeofday failed: %s", strerror(errno));
 }
+
+static void
+tsub(struct timeval *r, struct timeval *a, struct timeval *b)
+{
+	r->tv_sec = (time_t)(a->tv_sec - b->tv_sec);
+	r->tv_usec = (suseconds_t)(a->tv_usec - b->tv_usec);
+	if (r->tv_usec < 0) {
+		--r->tv_sec;
+		r->tv_usec += 1000000;
+	}
+}
+
+static void
+tmul(struct timeval *a, int b)
+{
+	a->tv_sec *= b;
+	a->tv_usec *= b;
+	if (a->tv_usec >= 1000000) {
+		++a->tv_sec;
+		a->tv_usec -= 1000000;
+	}
+}
+
 static long
 get_open_fd_max(void)
 {
@@ -322,27 +303,6 @@ clear(struct pid_list **list)
 	*list = NULL;
 }
 
-static int
-gid_in_current_groups(gid_t gid)
-{
-	gid_t *gids;
-	int i, ngroups;
-
-	ngroups = getgroups(0, NULL);
-	gids = xmalloc(ngroups * sizeof(gid_t));
-	getgroups(ngroups, gids);
-
-	for (i = 0; i < ngroups; i++) {
-		if (gid == gids[i]) {
-			free(gids);
-			return 1;
-		}
-	}
-
-	free(gids);
-	return 0;
-}
-
 static void
 do_help(void)
 {
@@ -1240,10 +1200,12 @@ run_stop_schedule(void)
 				if (ratio < 10)
 					ratio++;
 
-				TVCALC(interval, TVELEM(&after) * ratio -
-				                 TVELEM(&before) + TVADJUST);
-				TVCALC(maxinterval, TVELEM(&stopat) -
-				                    TVELEM(&after) + TVADJUST);
+				tsub(&maxinterval, &stopat, &after);
+				tsub(&interval, &after, &before);
+				tmul(&interval, ratio);
+
+				if (interval.tv_sec < 0 || interval.tv_usec < 0)
+					interval.tv_sec = interval.tv_usec = 0;
 
 				if (timercmp(&interval, &maxinterval, >))
 					interval = maxinterval;
@@ -1285,6 +1247,8 @@ int
 main(int argc, char **argv)
 {
 	int devnull_fd = -1;
+	gid_t rgid;
+	uid_t ruid;
 #ifdef HAVE_TIOCNOTTY
 	int tty_fd = -1;
 #endif
@@ -1413,18 +1377,25 @@ main(int argc, char **argv)
 	if (chdir(changedir) < 0)
 		fatal("Unable to chdir() to %s", changedir);
 
-	if (changegroup != NULL && *changegroup != '\0' &&
-	    getgid() != (gid_t)runas_gid) {
-		if (!gid_in_current_groups(runas_gid))
+	rgid = getgid();
+	ruid = getuid();
+	if (changegroup != NULL) {
+		if (rgid != (gid_t)runas_gid)
+			if (setgid(runas_gid))
+				fatal("Unable to set gid to %d", runas_gid);
+	}
+	if (changeuser != NULL) {
+		/* We assume that if our real user and group are the same as
+		 * the ones we should switch to, the supplementary groups
+		 * will be already in place. */
+		if (rgid != (gid_t)runas_gid || ruid != (uid_t)runas_uid)
 			if (initgroups(changeuser, runas_gid))
 				fatal("Unable to set initgroups() with gid %d",
 				      runas_gid);
-		if (setgid(runas_gid))
-			fatal("Unable to set gid to %d", runas_gid);
-	}
-	if (changeuser != NULL && getuid() != (uid_t)runas_uid) {
-		if (setuid(runas_uid))
-			fatal("Unable to set uid to %s", changeuser);
+
+		if (ruid != (uid_t)runas_uid)
+			if (setuid(runas_uid))
+				fatal("Unable to set uid to %s", changeuser);
 	}
 
 	if (background) {