diff -Nru cifs-utils-5.1/debian/changelog cifs-utils-5.1/debian/changelog --- cifs-utils-5.1/debian/changelog 2011-10-17 16:34:43.000000000 +0200 +++ cifs-utils-5.1/debian/changelog 2013-04-26 15:17:35.000000000 +0200 @@ -1,3 +1,18 @@ +cifs-utils (2:5.1-1ubuntu2) precise-proposed; urgency=low + + * mount.cifs: Properly update mtab during remount (LP: #1144612) + + During a remount of a cifs filesystem, the mtab file is not properly + updated, which leads to a doubled entry of the same filesystem in the + /etc/mtab file. This patch adds a new function del_mtab() which is + called before the add_mtab() in case the fs is being remounted. + + The del_mtab() function will delete from the mtab, the old entry from + the filesystem which is being remounted, and then, calls add_mtab() to + add an updated entry to the mtab file. + + -- Louis Bouchard Fri, 26 Apr 2013 15:15:32 +0200 + cifs-utils (2:5.1-1ubuntu1) precise; urgency=low * Merge from debian unstable. Remaining changes: diff -Nru cifs-utils-5.1/debian/patches/fix-double-mtab-entry-on-remount.patch cifs-utils-5.1/debian/patches/fix-double-mtab-entry-on-remount.patch --- cifs-utils-5.1/debian/patches/fix-double-mtab-entry-on-remount.patch 1970-01-01 01:00:00.000000000 +0100 +++ cifs-utils-5.1/debian/patches/fix-double-mtab-entry-on-remount.patch 2013-04-26 15:14:10.000000000 +0200 @@ -0,0 +1,154 @@ + +From: Carlos Maiolino +Date: Mon, 16 Jan 2012 17:29:49 +0000 (-0500) +Subject: mount.cifs: Properly update mtab during remount +X-Git-Tag: cifs-utils-5.3~18 +X-Git-Url: https://git.samba.org/?p=cifs-utils.git;a=commitdiff_plain;h=f46dd7661cfb87257c95081fc2071c934bfbbb16 + +mount.cifs: Properly update mtab during remount + +During a remount of a cifs filesystem, the mtab file is not properly +updated, which leads to a doubled entry of the same filesystem in the +/etc/mtab file. This patch adds a new function del_mtab() which is +called before the add_mtab() in case the fs is being remounted. + +The del_mtab() function will delete from the mtab, the old entry from +the filesystem which is being remounted, and then, calls add_mtab() to +add an updated entry to the mtab file. + +Origin: https://git.samba.org/?p=cifs-utils.git;a=commitdiff_plain;h=f46dd7661cfb87257c95081fc2071c934bfbbb16 +Bug-Ubuntu: http://bugs.launchpad.net/bugs/1144612 + +Signed-off-by: Carlos Maiolino +--- + +--- a/mount.cifs.c ++++ b/mount.cifs.c +@@ -42,6 +42,7 @@ + #include + #include + #include ++#include + #include + #include + #ifdef HAVE_LIBCAP_NG +@@ -159,6 +160,7 @@ + #define OPT_NOMAND 28 + #define OPT_CRUID 29 + ++#define MNT_TMP_FILE "/.mtab.cifs.XXXXXX" + + /* struct for holding parsed mount info for use by privleged process */ + struct parsed_mount_info { +@@ -1548,6 +1550,94 @@ + return rc; + } + ++static int ++del_mtab(char *mountpoint) ++{ ++ int tmprc, rc = 0; ++ FILE *mnttmp, *mntmtab; ++ struct mntent *mountent; ++ char *mtabfile, *mtabdir, *mtabtmpfile; ++ ++ mtabfile = strdup(MOUNTED); ++ mtabdir = dirname(mtabfile); ++ mtabdir = realloc(mtabdir, strlen(mtabdir) + strlen(MNT_TMP_FILE) + 2); ++ if (!mtabdir) { ++ fprintf(stderr, "del_mtab: cannot determine current mtab path"); ++ rc = EX_FILEIO; ++ goto del_mtab_exit; ++ } ++ ++ mtabtmpfile = strcat(mtabdir, MNT_TMP_FILE); ++ if (!mtabtmpfile) { ++ fprintf(stderr, "del_mtab: cannot allocate memory to tmp file"); ++ rc = EX_FILEIO; ++ goto del_mtab_exit; ++ } ++ ++ atexit(unlock_mtab); ++ rc = lock_mtab(); ++ if (rc) { ++ fprintf(stderr, "del_mtab: cannot lock mtab"); ++ rc = EX_FILEIO; ++ goto del_mtab_exit; ++ } ++ ++ mtabtmpfile = mktemp(mtabtmpfile); ++ if (!mtabtmpfile) { ++ fprintf(stderr, "del_mtab: cannot setup tmp file destination"); ++ rc = EX_FILEIO; ++ goto del_mtab_exit; ++ } ++ ++ mntmtab = setmntent(MOUNTED, "r"); ++ if (!mntmtab) { ++ fprintf(stderr, "del_mtab: could not update mount table\n"); ++ rc = EX_FILEIO; ++ goto del_mtab_exit; ++ } ++ ++ mnttmp = setmntent(mtabtmpfile, "w"); ++ if (!mnttmp) { ++ fprintf(stderr, "del_mtab: could not update mount table\n"); ++ endmntent(mntmtab); ++ rc = EX_FILEIO; ++ goto del_mtab_exit; ++ } ++ ++ while ((mountent = getmntent(mntmtab)) != NULL) { ++ if (!strcmp(mountent->mnt_dir, mountpoint)) ++ continue; ++ rc = addmntent(mnttmp, mountent); ++ if (rc) { ++ fprintf(stderr, "del_mtab: unable to add mount entry to mtab\n"); ++ rc = EX_FILEIO; ++ goto del_mtab_error; ++ } ++ } ++ ++ endmntent(mntmtab); ++ ++ tmprc = my_endmntent(mnttmp, 0); ++ if (tmprc) { ++ fprintf(stderr, "del_mtab: error %d detected on close of tmp file\n", tmprc); ++ rc = EX_FILEIO; ++ goto del_mtab_error; ++ } ++ ++ rename(mtabtmpfile, MOUNTED); ++ ++del_mtab_exit: ++ unlock_mtab(); ++ free(mtabdir); ++ return rc; ++ ++del_mtab_error: ++ if (unlink(mtabtmpfile)) ++ fprintf(stderr, "del_mtab: failed to delete tmp file - %s\n", ++ strerror(errno)); ++ goto del_mtab_exit; ++} ++ + /* have the child drop root privileges */ + static int + drop_child_privs(void) +@@ -1945,8 +2035,15 @@ + } + + do_mtab: +- if (!parsed_info->nomtab && !mtab_unusable()) ++ if (!parsed_info->nomtab && !mtab_unusable()) { ++ if (parsed_info->flags & MS_REMOUNT) { ++ rc = del_mtab(mountpoint); ++ if (rc) ++ goto mount_exit; ++ } ++ + rc = add_mtab(orig_dev, mountpoint, parsed_info->flags, fstype); ++ } + + mount_exit: + if (parsed_info) { diff -Nru cifs-utils-5.1/debian/patches/series cifs-utils-5.1/debian/patches/series --- cifs-utils-5.1/debian/patches/series 1970-01-01 01:00:00.000000000 +0100 +++ cifs-utils-5.1/debian/patches/series 2013-04-26 15:11:34.000000000 +0200 @@ -0,0 +1 @@ +fix-double-mtab-entry-on-remount.patch