d47b309
diff --git a/modules/pam_namespace/namespace.conf.5.xml b/modules/pam_namespace/namespace.conf.5.xml
d47b309
index 673099b..f28350d 100644
d47b309
--- a/modules/pam_namespace/namespace.conf.5.xml
d47b309
+++ b/modules/pam_namespace/namespace.conf.5.xml
d47b309
@@ -119,6 +119,14 @@
d47b309
       contain the user name and will be shared among all users.
d47b309
     </para>
d47b309
 
d47b309
+    <para><emphasis>mntopts</emphasis>=<replaceable>value</replaceable>
d47b309
+      - this flag value is passed to the mount call when the tmpfs mount is done.
d47b309
+      It allows for example the specification of the maximum size of the tmpfs
d47b309
+      instance that is created by the mount call. See <citerefentry>
d47b309
+      <refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum>
d47b309
+      </citerefentry> for details.
d47b309
+    </para>
d47b309
+
d47b309
     <para>
d47b309
       The directory where polyinstantiated instances are to be
d47b309
       created, must exist and must have, by default, the mode of 0000.  The
d47b309
diff --git a/modules/pam_namespace/pam_namespace.c b/modules/pam_namespace/pam_namespace.c
d47b309
index a40f05e..e0d5e30 100644
d47b309
--- a/modules/pam_namespace/pam_namespace.c
d47b309
+++ b/modules/pam_namespace/pam_namespace.c
d47b309
@@ -64,6 +64,7 @@ static void del_polydir(struct polydir_s *poly)
d47b309
 	if (poly) {
d47b309
 		free(poly->uid);
d47b309
 		free(poly->init_script);
d47b309
+		free(poly->mount_opts);
d47b309
 		free(poly);
d47b309
 	}
d47b309
 }
d47b309
@@ -237,9 +238,9 @@ static int parse_method(char *method, struct polydir_s *poly,
d47b309
     static const char *method_names[] = { "user", "context", "level", "tmpdir",
d47b309
 	"tmpfs", NULL };
d47b309
     static const char *flag_names[] = { "create", "noinit", "iscript",
d47b309
-	"shared", NULL };
d47b309
+	"shared", "mntopts", NULL };
d47b309
     static const unsigned int flag_values[] = { POLYDIR_CREATE, POLYDIR_NOINIT,
d47b309
-	POLYDIR_ISCRIPT, POLYDIR_SHARED };
d47b309
+	POLYDIR_ISCRIPT, POLYDIR_SHARED, POLYDIR_MNTOPTS };
d47b309
     int i;
d47b309
     char *flag;
d47b309
 
d47b309
@@ -279,6 +280,20 @@ static int parse_method(char *method, struct polydir_s *poly,
d47b309
 					return -1;
d47b309
 				};
d47b309
 				break;
d47b309
+
d47b309
+			    case POLYDIR_MNTOPTS:
d47b309
+				if (flag[namelen] != '=')
d47b309
+					break;
d47b309
+				if (poly->method != TMPFS) {
d47b309
+					pam_syslog(idata->pamh, LOG_WARNING, "Mount options applicable only to tmpfs method");
d47b309
+					break;
d47b309
+				}
d47b309
+				free(poly->mount_opts); /* if duplicate mntopts specified */
d47b309
+				if ((poly->mount_opts = strdup(flag+namelen+1)) == NULL) {
d47b309
+					pam_syslog(idata->pamh, LOG_CRIT, "Memory allocation error");
d47b309
+					return -1;
d47b309
+				}
d47b309
+				break;
d47b309
 			}
d47b309
 		}
d47b309
 	}
d47b309
@@ -1464,7 +1479,7 @@ static int ns_setup(struct polydir_s *polyptr,
d47b309
     }
d47b309
 
d47b309
     if (polyptr->method == TMPFS) {
d47b309
-	if (mount("tmpfs", polyptr->dir, "tmpfs", 0, NULL) < 0) {
d47b309
+	if (mount("tmpfs", polyptr->dir, "tmpfs", 0, polyptr->mount_opts) < 0) {
d47b309
 	    pam_syslog(idata->pamh, LOG_ERR, "Error mounting tmpfs on %s, %m",
d47b309
 		polyptr->dir);
d47b309
             return PAM_SESSION_ERR;
d47b309
diff --git a/modules/pam_namespace/pam_namespace.h b/modules/pam_namespace/pam_namespace.h
d47b309
index 51d2388..47ebcc3 100644
d47b309
--- a/modules/pam_namespace/pam_namespace.h
d47b309
+++ b/modules/pam_namespace/pam_namespace.h
d47b309
@@ -116,6 +116,7 @@
d47b309
 #define POLYDIR_NOINIT        0x00000004 /* no init script */
d47b309
 #define POLYDIR_SHARED        0x00000008 /* share context/level instances among users */
d47b309
 #define POLYDIR_ISCRIPT       0x00000010 /* non default init script */
d47b309
+#define POLYDIR_MNTOPTS       0x00000020 /* mount options for tmpfs mount */
d47b309
 
d47b309
 
d47b309
 #define NAMESPACE_MAX_DIR_LEN 80
d47b309
@@ -164,6 +165,7 @@ struct polydir_s {
d47b309
     uid_t *uid;				/* list of override uids */
d47b309
     unsigned int flags;			/* polydir flags */
d47b309
     char *init_script;			/* path to init script */
d47b309
+    char *mount_opts;			/* mount options for tmpfs mount */
d47b309
     uid_t owner;			/* user which should own the polydir */
d47b309
     gid_t group;			/* group which should own the polydir */
d47b309
     mode_t mode;			/* mode of the polydir */