a Btrfs subvolume is created
regardless of any configuration file settings.
</para>
+ <para>
+ Subvolumes are only created for regular users,
+ whose UID is within the
+ <option>UID_MIN</option>-<option>UID_MAX</option>
+ range defined in <filename>/etc/login.defs</filename>.
+ System users get a regular home directory instead.
+ Set the <option>BTRFS_SUBVOLUME_SYSTEM</option> variable
+ in <filename>/etc/default/useradd</filename>
+ to <replaceable>yes</replaceable>
+ to create subvolumes for system users as well.
+ If this variable is not set,
+ the default value is no.
+ </para>
<para>
If the parent directory of the user's home directory is
<emphasis>not</emphasis> on a Btrfs filesystem,
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_btrfs_subvolume_system = "no";
static const char *def_log_init = "yes";
static long def_inactive = -1;
#define DUSRSKEL "USRSKEL"
#define DCREATE_MAIL_SPOOL "CREATE_MAIL_SPOOL"
#define DBTRFS_SUBVOLUME_HOME "BTRFS_SUBVOLUME_HOME"
+#define DBTRFS_SUBVOLUME_SYSTEM "BTRFS_SUBVOLUME_SYSTEM"
#define DLOG_INIT "LOG_INIT"
/* local function prototypes */
def_btrfs_subvolume_home = xstrdup(ccp);
}
+ /*
+ * Create subvolume homes also for system users?
+ */
+ else if (streq(buf, DBTRFS_SUBVOLUME_SYSTEM)) {
+ if (streq(ccp, ""))
+ ccp = "no";
+ def_btrfs_subvolume_system = xstrdup(ccp);
+ }
+
/*
* By default do we add the user to the lastlog and faillog databases ?
*/
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 ("BTRFS_SUBVOLUME_SYSTEM=%s\n", def_btrfs_subvolume_system);
printf ("LOG_INIT=%s\n", def_log_init);
}
bool out_usrskel = false;
bool out_create_mail_spool = false;
bool out_btrfs_subvolume_home = false;
+ bool out_btrfs_subvolume_system = false;
bool out_log_init = false;
char buf[1024];
char *new_file = NULL;
DBTRFS_SUBVOLUME_HOME "=%s\n",
def_btrfs_subvolume_home);
out_btrfs_subvolume_home = true;
+ } else if (!out_btrfs_subvolume_system && streq(buf, DBTRFS_SUBVOLUME_SYSTEM)) {
+ fprintf(ofp,
+ DBTRFS_SUBVOLUME_SYSTEM "=%s\n",
+ def_btrfs_subvolume_system);
+ out_btrfs_subvolume_system = true;
} else if (!out_log_init && streq(buf, DLOG_INIT)) {
fprintf(ofp, DLOG_INIT "=%s\n", def_log_init);
out_log_init = true;
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_btrfs_subvolume_system)
+ fprintf (ofp, DBTRFS_SUBVOLUME_SYSTEM "=%s\n", def_btrfs_subvolume_system);
if (!out_log_init)
fprintf (ofp, DLOG_INIT "=%s\n", def_log_init);
/*
static bool
want_btrfs_subvolume(const char *path)
{
+ uid_t min, max;
+
if (!subvolflg)
return false;
+ if (strlen(prefix_user_home) - strlen(path) > 1)
+ return false;
+
+ if (strcaseeq(def_btrfs_subvolume_system, "yes"))
+ return true;
+
+ min = getdef_ulong("UID_MIN", 1000UL);
+ max = getdef_ulong("UID_MAX", 60000UL);
- return strlen(prefix_user_home) - strlen(path) <= 1;
+ return user_id >= min && user_id <= max;
}
#endif