From 46043b24caf3ccbaeef3fdfaeb7edcc6c99e6a58 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Mon, 23 Aug 2010 14:48:42 -0700 Subject: move "changed" status handling into library * remove public status modifier as high-level operations no longer need it. * add more information to clarify changed status handling in library. * mark changed status at appropriate places in library. --- src/common/unionfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/unionfs.c b/src/common/unionfs.c index 85ea9f1..da4cd7e 100644 --- a/src/common/unionfs.c +++ b/src/common/unionfs.c @@ -730,7 +730,7 @@ common_commit_copy_to_live_config(GNode *node, boolean suppress_piecewise_copy, /* note: return status is not checked and operation continues even if * this fails. this follows the original logic. */ - cstore_unmark_cfg_path_changed(cs, pcomps, ncomps); + cstore_unmark_cfg_path_changed(cs, (const char **) pcomps, ncomps); cstore_free_path_comps(pcomps, ncomps); cstore_free(cs); } -- cgit v1.2.3 From efe1f2b5aea0065f94394b916f1fa8b447229d5a Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Thu, 26 Aug 2010 19:04:24 -0700 Subject: fix for bug 5960 * change "commit" to use syscalls (instead of system("...") calls) for mount/umount. * this is a temporary fix, and such low-level details need to be moved into the backend library. --- debian/vyatta-cfg.postinst.in | 2 +- src/common/unionfs.c | 65 +++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 37 deletions(-) (limited to 'src/common') diff --git a/debian/vyatta-cfg.postinst.in b/debian/vyatta-cfg.postinst.in index c007538..bb747d4 100644 --- a/debian/vyatta-cfg.postinst.in +++ b/debian/vyatta-cfg.postinst.in @@ -28,7 +28,7 @@ if [ "$sysconfdir" != "/etc" ]; then fi # capability stuff -for bin in my_cli_bin my_cli_shell_api; do +for bin in my_cli_bin my_cli_shell_api my_commit; do touch -ac $sbindir/$bin setcap cap_sys_admin=pe $sbindir/$bin done diff --git a/src/common/unionfs.c b/src/common/unionfs.c index da4cd7e..9fe2497 100644 --- a/src/common/unionfs.c +++ b/src/common/unionfs.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,10 @@ extern vtw_path t_path; * behavior so no status is returned (since system() return code was not * checked). this should probably be changed so each invocation is checked * for error. + * + * XXX these (and many other things here) will need to be moved into the + * library to consolidate the usage of all low-level implementation + * details. */ static inline void sys_mkdir_p(const char *path) @@ -54,6 +59,25 @@ sys_cp(const char *src_file, const char *dst_file) } } +static inline void +sys_umount_session() +{ + if (umount(get_mdirp()) != 0) { + perror("umount"); + } +} + +static inline void +sys_mount_session() +{ + char mopts[MAX_LENGTH_DIR_PATH * 2]; + snprintf(mopts, MAX_LENGTH_DIR_PATH * 2, "dirs=%s=rw:%s=ro", + get_cdirp(), get_adirp()); + if (mount("unionfs", get_mdirp(), "unionfs", 0, mopts) != 0) { + perror("mount"); + } +} + void set_path(char *path, boolean config); @@ -743,9 +767,6 @@ common_commit_copy_to_live_config(GNode *node, boolean suppress_piecewise_copy, static const char format1point1[]="mv -f %s/* -t %s"; /*mdirp, tmpp*/ static const char format1point5[]="rm -fr '%s'/*"; /*tmpp*/ - static const char format2[]="sudo umount %s"; //mdirp - static const char format8[]="sudo mount -t unionfs -o dirs=%s=rw:%s=ro unionfs %s"; //cdirp, adirp, mdirp - set_echo(TRUE); char mbuf[MAX_LENGTH_DIR_PATH]; @@ -802,15 +823,9 @@ common_commit_copy_to_live_config(GNode *node, boolean suppress_piecewise_copy, system(command); } - //unmount temp (i.e. rm merge) - sprintf(command, format2, mbuf_root); - if (g_debug) { - printf("%s\n",command); - syslog(LOG_DEBUG,"%s\n",command); - fflush(NULL); - } + // unmount the session dir if (test_mode == FALSE) { - system(command); + sys_umount_session(); } if (suppress_piecewise_copy) { @@ -837,14 +852,8 @@ common_commit_copy_to_live_config(GNode *node, boolean suppress_piecewise_copy, piecewise_copy(node, test_mode); } - sprintf(command, format8, cbuf_root,abuf_root,mbuf_root); - if (g_debug) { - printf("%s\n",command); - syslog(LOG_DEBUG,"%s\n",command); - fflush(NULL); - } if (test_mode == FALSE) { - system(command); + sys_mount_session(); } fflush(NULL); @@ -876,10 +885,7 @@ common_commit_clean_temp_config(GNode *root_node, boolean test_mode) char *command; command = malloc(MAX_LENGTH_DIR_PATH); /* XXX must ... remove ... this ... */ - static const char format2[]="sudo umount %s"; //mdirp static const char format5[]="rm -fr '%s'/{.*,*} >&/dev/null ; /bin/true"; /*cdirp*/ - static const char format7[]="sudo mount -t unionfs -o dirs=%s=rw:%s=ro unionfs %s"; //cdirp, adirp, mdirp - char tbuf[MAX_LENGTH_DIR_PATH]; sprintf(tbuf,"%s",get_tmpp()); @@ -892,15 +898,8 @@ common_commit_clean_temp_config(GNode *root_node, boolean test_mode) set_echo(TRUE); - sprintf(command, format2, mbuf); - if (g_debug) { - printf("%s\n",command); - syslog(LOG_DEBUG,"%s\n",command); - fflush(NULL); - } - if (test_mode == FALSE) { - system(command); + sys_umount_session(); } /* @@ -939,14 +938,8 @@ common_commit_clean_temp_config(GNode *root_node, boolean test_mode) system(command); } - sprintf(command, format7, cbuf,abuf,mbuf); - if (g_debug) { - printf("%s\n",command); - syslog(LOG_DEBUG,"%s\n",command); - fflush(NULL); - } if (test_mode == FALSE) { - system(command); + sys_mount_session(); } /* notify other users in config mode */ -- cgit v1.2.3 From cfa746fb0d41a70843a851561136dc003745f14f Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Tue, 3 Aug 2010 13:48:11 -0700 Subject: fix for bug 5982. upped max_length_buffer length from 1024 to 4096. Should leave open and reassign to mendocino so that a proper string length check can be added to the commit. (cherry picked from commit df3c80575ea539e560afc3357eb322e3e9df64bf) --- src/common/unionfs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/unionfs.h b/src/common/unionfs.h index 7881594..362972e 100644 --- a/src/common/unionfs.h +++ b/src/common/unionfs.h @@ -30,8 +30,8 @@ #define WHITEOUT_DISABLE_FILE ".wh..disable" #define DELETED_NODE ".wh." -#define MAX_LENGTH_DIR_PATH 1024 -#define MAX_LENGTH_HELP_STR 1024 +#define MAX_LENGTH_DIR_PATH 4096 +#define MAX_LENGTH_HELP_STR 4096 boolean value_exists(char *path); -- cgit v1.2.3