Bug#329403: [Buildd-tools-devel] Bug#329403: schroot: Clobbers files
in the chroot without warning
Roger Leigh
rleigh at whinlatter.ukfsn.org
Wed Sep 21 20:06:41 UTC 2005
tags 329403 + confirmed fixed-upstream pending
thanks
Roger Leigh <rleigh at whinlatter.ukfsn.org> writes:
> Daniel Jacobowitz <dan at debian.org> writes:
>
>> Enabling the scripts on a per-chroot basis in schroot.conf perhaps?
>
> That's even better, thanks.
I've installed the following changes into CVS to fix this. This will
be uploaded to Debian in a few days, pending some other changes.
Regards,
Roger
Index: ChangeLog
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/ChangeLog,v
retrieving revision 1.53
diff -u -r1.53 ChangeLog
--- ChangeLog 20 Sep 2005 21:21:11 -0000 1.53
+++ ChangeLog 21 Sep 2005 20:02:26 -0000
@@ -1,4 +1,24 @@
-2005-09-20 Roger Leigh <rleigh at whinlatter.ukfsn.org>
+2005-09-21 Roger Leigh <rleigh at whinlatter.ukfsn.org>
+
+ * debian/changelog: Bump version to 0.1.6. Document run-setup
+ changes for Debian Bug #329403.
+
+ * schroot/schroot.conf.5.in: Document "run-setup" configuration
+ option.
+
+ * schroot/sbuild-session.c (sbuild_session_run): Only run setup
+ scripts if enabled in the chroot configuration.
+
+ * schroot/sbuild-chroot.c
+ (sbuild_chroot_class_init): Add "run-setup" property, and
+ associated accessors.
+ (sbuild_chroot_new_from_keyfile): Add support for G_TYPE_BOOLEAN
+ properties as configuration options.
+
+ * schroot/sbuild-chroot.h (struct _SbuildChroot): Add run_setup
+ member.
+
+2005-09-20 Roger Leigh <rleigh at debian.org>
* schroot/sbuild-chroot.c
(sbuild_chroot_new_from_keyfile): Fix a memory leak during chroot
Index: debian/changelog
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/debian/changelog,v
retrieving revision 1.11
diff -u -r1.11 changelog
--- debian/changelog 11 Sep 2005 15:39:20 -0000 1.11
+++ debian/changelog 21 Sep 2005 20:02:27 -0000
@@ -1,3 +1,14 @@
+schroot (0.1.6-1) unstable; urgency=low
+
+ * New upstream release.
+ * Don't run setup scripts by default, because this can cause
+ data loss with custom chroot setups. A "run-setup" chroot
+ option has been added to configure the running of setup
+ scripts, which are disabled by default for safety
+ (Closes: #329403).
+
+ -- Roger Leigh <rleigh at debian.org> Wed, 21 Sep 2005 20:46:30 +0100
+
schroot (0.1.5-1) unstable; urgency=low
* New upstream release.
Index: doc/schroot/tmpl/sbuild-chroot.sgml
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/doc/schroot/tmpl/sbuild-chroot.sgml,v
retrieving revision 1.11
diff -u -r1.11 sbuild-chroot.sgml
--- doc/schroot/tmpl/sbuild-chroot.sgml 18 Sep 2005 20:57:52 -0000 1.11
+++ doc/schroot/tmpl/sbuild-chroot.sgml 21 Sep 2005 20:02:27 -0000
@@ -78,6 +78,11 @@
</para>
+<!-- ##### ARG SbuildChroot:run-setup ##### -->
+<para>
+
+</para>
+
<!-- ##### STRUCT SbuildChrootClass ##### -->
<para>
SbuildChroot class.
Index: schroot/sbuild-chroot.c
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/schroot/sbuild-chroot.c,v
retrieving revision 1.16
diff -u -r1.16 sbuild-chroot.c
--- schroot/sbuild-chroot.c 20 Sep 2005 21:21:11 -0000 1.16
+++ schroot/sbuild-chroot.c 21 Sep 2005 20:02:27 -0000
@@ -62,7 +62,8 @@
PROP_MOUNT_DEVICE,
PROP_CURRENT_USERS,
PROP_MAX_USERS,
- PROP_ACTIVE
+ PROP_ACTIVE,
+ PROP_RUN_SETUP
};
static GObjectClass *parent_class;
@@ -194,7 +195,24 @@
params = g_renew (GParameter, params, n_alloc_params);
}
- if (G_PARAM_SPEC_VALUE_TYPE(pspec) == G_TYPE_UINT)
+ if (G_PARAM_SPEC_VALUE_TYPE(pspec) == G_TYPE_BOOLEAN)
+ {
+ gboolean value =
+ g_key_file_get_boolean(keyfile, group, key, &error);
+
+ if (error != NULL)
+ g_clear_error(&error);
+ else
+ {
+ params[n_params].name = key;
+ params[n_params].value.g_type = 0;
+ g_value_init (¶ms[n_params].value,
+ G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_value_set_boolean(¶ms[n_params].value, value);
+ ++n_params;
+ }
+ }
+ else if (G_PARAM_SPEC_VALUE_TYPE(pspec) == G_TYPE_UINT)
{
gint num =
g_key_file_get_integer(keyfile, group, key, &error);
@@ -659,6 +677,39 @@
}
/**
+ * sbuild_chroot_get_run_setup:
+ * @chroot: an #SbuildChroot
+ *
+ * Check if chroot setup scripts will be run.
+ *
+ * Returns TRUE if setup scripts will be run, otherwise FALSE.
+ */
+gboolean
+sbuild_chroot_get_run_setup (const SbuildChroot *restrict chroot)
+{
+ g_return_val_if_fail(SBUILD_IS_CHROOT(chroot), FALSE);
+
+ return chroot->run_setup;
+}
+
+/**
+ * sbuild_chroot_set_run_setup:
+ * @chroot: an #SbuildChroot.
+ * @run_setup: TRUE to run setup scripts, otherwise FALSE.
+ *
+ * Set whether chroot setup scripts should be run or not.
+ */
+void
+sbuild_chroot_set_run_setup (SbuildChroot *chroot,
+ gboolean run_setup)
+{
+ g_return_if_fail(SBUILD_IS_CHROOT(chroot));
+
+ chroot->run_setup = run_setup;
+ g_object_notify(G_OBJECT(chroot), "run-setup");
+}
+
+/**
* sbuild_chroot_get_chroot_type:
* @chroot: an #SbuildChroot
*
@@ -721,6 +772,8 @@
g_free(alias_list);
g_fprintf(file, _(" %-22s%u\n"), _("Maximum Users"), chroot->max_users);
+ g_fprintf(file, _(" %-22s%s\n"), _("Run Setup"),
+ (chroot->run_setup == TRUE) ? "true" : "false");
SbuildChrootClass *klass = SBUILD_CHROOT_GET_CLASS(chroot);
if (klass->print_details)
@@ -777,6 +830,8 @@
}
g_fprintf(file, "max-users=%u\n", chroot->max_users);
+ g_fprintf(file, _("run-setup=%s\n"),
+ (chroot->run_setup == TRUE) ? "true" : "false");
SbuildChrootClass *klass = SBUILD_CHROOT_GET_CLASS(chroot);
if (klass->print_config)
@@ -851,6 +906,7 @@
chroot->current_users = 0;
chroot->max_users = 0;
chroot->active = FALSE;
+ chroot->run_setup = FALSE;
}
static void
@@ -943,6 +999,9 @@
case PROP_MAX_USERS:
sbuild_chroot_set_max_users(chroot, g_value_get_uint(value));
break;
+ case PROP_RUN_SETUP:
+ sbuild_chroot_set_run_setup(chroot, g_value_get_boolean(value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -997,6 +1056,9 @@
case PROP_ACTIVE:
g_value_set_boolean(value, chroot->active);
break;
+ case PROP_RUN_SETUP:
+ g_value_set_boolean(value, chroot->run_setup);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -1105,6 +1167,14 @@
"Is the chroot currently in use?",
FALSE,
(G_PARAM_READABLE)));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_RUN_SETUP,
+ g_param_spec_boolean ("run-setup", "Run Setup",
+ "Run chroot setup scripts?",
+ FALSE,
+ (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
}
/*
Index: schroot/sbuild-chroot.h
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/schroot/sbuild-chroot.h,v
retrieving revision 1.7
diff -u -r1.7 sbuild-chroot.h
--- schroot/sbuild-chroot.h 18 Sep 2005 20:57:52 -0000 1.7
+++ schroot/sbuild-chroot.h 21 Sep 2005 20:02:27 -0000
@@ -58,6 +58,7 @@
guint current_users;
guint max_users;
gboolean active;
+ gboolean run_setup;
};
struct _SbuildChrootClass
@@ -151,6 +152,13 @@
sbuild_chroot_set_max_users (SbuildChroot *chroot,
guint max_users);
+gboolean
+sbuild_chroot_get_run_setup (const SbuildChroot *restrict chroot);
+
+void
+sbuild_chroot_set_run_setup (SbuildChroot *chroot,
+ gboolean run_setup);
+
const gchar *
sbuild_chroot_get_chroot_type (const SbuildChroot *chroot);
Index: schroot/sbuild-session.c
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/schroot/sbuild-session.c,v
retrieving revision 1.33
diff -u -r1.33 sbuild-session.c
--- schroot/sbuild-session.c 18 Sep 2005 20:57:52 -0000 1.33
+++ schroot/sbuild-session.c 21 Sep 2005 20:02:28 -0000
@@ -874,18 +874,20 @@
else
{
/* Run chroot setup scripts. */
- sbuild_session_setup_chroot(session, chroot,
- SBUILD_SESSION_CHROOT_SETUP_START,
- &tmp_error);
+ if (sbuild_chroot_get_run_setup(chroot) == TRUE)
+ sbuild_session_setup_chroot(session, chroot,
+ SBUILD_SESSION_CHROOT_SETUP_START,
+ &tmp_error);
/* Run session if setup succeeded. */
if (tmp_error == NULL)
sbuild_session_run_chroot(session, chroot, &tmp_error);
/* Run clean up scripts whether or not there was an error. */
- sbuild_session_setup_chroot(session, chroot,
- SBUILD_SESSION_CHROOT_SETUP_STOP,
- (tmp_error != NULL) ? NULL : &tmp_error);
+ if (sbuild_chroot_get_run_setup(chroot) == TRUE)
+ sbuild_session_setup_chroot(session, chroot,
+ SBUILD_SESSION_CHROOT_SETUP_STOP,
+ (tmp_error != NULL) ? NULL : &tmp_error);
}
if (tmp_error != NULL)
Index: schroot/schroot.conf.5.in
===================================================================
RCS file: /cvsroot/buildd-tools/schroot/schroot/schroot.conf.5.in,v
retrieving revision 1.12
diff -u -r1.12 schroot.conf.5.in
--- schroot/schroot.conf.5.in 18 Sep 2005 20:57:52 -0000 1.12
+++ schroot/schroot.conf.5.in 21 Sep 2005 20:02:28 -0000
@@ -76,6 +76,10 @@
.B max-users=\fInumber\fP
Set the maximum number of users allowed to use the chroot. The default is 1
user, and the minimum is also 1.
+.TP
+.B run-setup=\fItrue\fP|\fIfalse\fP
+Set whether chroot setup scripts will be run. The default is not to run setup
+scripts (\[lq]false\[rq]).
.SS
Plain chroots
.PP
--
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
More information about the Buildd-tools-devel
mailing list