</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>
+ <option>--btrfs-subvolume-home</option>
+ </term>
+ <listitem>
+ <para>
+ Create the user's home directory as a Btrfs subvolume.
+ </para>
+ <para>
+ If this option is not specified,
+ <command>useradd</command> will follow the default behavior
+ defined by the <option>BTRFS_SUBVOLUME_HOME</option> variable
+ in <filename>/etc/default/useradd</filename>.
+ If this variable is not set, the default value is no.
+ </para>
+ <para>
+ When the <option>--btrfs-subvolume-home</option> command-line option
+ is specified,
+ a Btrfs subvolume is created
+ regardless of any configuration file settings.
+ </para>
+ <para>
+ Note: this feature works only if the underlying filesystem supports
+ Btrfs subvolumes.
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term>
<option>-c</option>, <option>--comment</option> <replaceable>COMMENT</replaceable>
static const char *def_template = SKEL_DIR;
static const char *def_usrtemplate = USRSKELDIR;
static const char *def_create_mail_spool = "yes";
+static const char *def_btrfs_subvolume_home = "no";
static const char *def_log_init = "yes";
static long def_inactive = -1;
#define DSKEL "SKEL"
#define DUSRSKEL "USRSKEL"
#define DCREATE_MAIL_SPOOL "CREATE_MAIL_SPOOL"
+#define DBTRFS_SUBVOLUME_HOME "BTRFS_SUBVOLUME_HOME"
#define DLOG_INIT "LOG_INIT"
/* local function prototypes */
def_usrtemplate = xstrdup(ccp);
}
}
+
/*
* Create by default user mail spool or not ?
*/
def_create_mail_spool = xstrdup(ccp);
}
+ /*
+ * Create home directories as Btrfs subvolumes by default?
+ */
+ else if (streq(buf, DBTRFS_SUBVOLUME_HOME)) {
+ if (streq(ccp, ""))
+ ccp = "no";
+ def_btrfs_subvolume_home = xstrdup(ccp);
+ }
+
/*
* By default do we add the user to the lastlog and faillog databases ?
*/
printf ("SKEL=%s\n", def_template);
printf ("USRSKEL=%s\n", def_usrtemplate);
printf ("CREATE_MAIL_SPOOL=%s\n", def_create_mail_spool);
+ printf ("BTRFS_SUBVOLUME_HOME=%s\n", def_btrfs_subvolume_home);
printf ("LOG_INIT=%s\n", def_log_init);
}
bool out_skel = false;
bool out_usrskel = false;
bool out_create_mail_spool = false;
+ bool out_btrfs_subvolume_home = false;
bool out_log_init = false;
char buf[1024];
char *new_file = NULL;
DCREATE_MAIL_SPOOL "=%s\n",
def_create_mail_spool);
out_create_mail_spool = true;
+ } else if (!out_btrfs_subvolume_home && streq(buf, DBTRFS_SUBVOLUME_HOME)) {
+ fprintf(ofp,
+ DBTRFS_SUBVOLUME_HOME "=%s\n",
+ def_btrfs_subvolume_home);
+ out_btrfs_subvolume_home = true;
} else if (!out_log_init && streq(buf, DLOG_INIT)) {
fprintf(ofp, DLOG_INIT "=%s\n", def_log_init);
out_log_init = true;
if (!out_create_mail_spool)
fprintf (ofp, DCREATE_MAIL_SPOOL "=%s\n", def_create_mail_spool);
+ if (!out_btrfs_subvolume_home)
+ fprintf (ofp, DBTRFS_SUBVOLUME_HOME "=%s\n", def_btrfs_subvolume_home);
if (!out_log_init)
fprintf (ofp, DLOG_INIT "=%s\n", def_log_init);
/*
}
}
+ if (!subvolflg && strcaseeq(def_btrfs_subvolume_home, "yes"))
+ subvolflg = true;
+
if (!gflg && !Nflg && !Uflg) {
/* Get the settings from login.defs */
Uflg = getdef_bool ("USERGROUPS_ENAB");