[libtrash] Resolves: #1096443 - avoid symbol clashes when loading audacious plug-ins

Kamil Dudka kdudka at fedoraproject.org
Mon May 12 11:54:05 UTC 2014


commit 588519ead9f85c54eef23eb80550c2d93a725ff3
Author: Kamil Dudka <kdudka at redhat.com>
Date:   Mon May 12 13:42:10 2014 +0200

    Resolves: #1096443 - avoid symbol clashes when loading audacious plug-ins

 libtrash-3.2-bz1096443.patch |  419 ++++++++++++++++++++++++++++++++++++++++++
 libtrash.spec                |   13 +-
 2 files changed, 430 insertions(+), 2 deletions(-)
---
diff --git a/libtrash-3.2-bz1096443.patch b/libtrash-3.2-bz1096443.patch
new file mode 100644
index 0000000..a3bca68
--- /dev/null
+++ b/libtrash-3.2-bz1096443.patch
@@ -0,0 +1,419 @@
+From 6c0073acfac086ca38d370d0836c314ccef431e0 Mon Sep 17 00:00:00 2001
+From: Kamil Dudka <kdudka at redhat.com>
+Date: Mon, 12 May 2014 13:35:23 +0200
+Subject: [PATCH] rename init/fini to libtrash_init/libtrash_fini
+
+... in order to avoid symbol clashes when loading audacious plug-ins
+
+Bug: https://bugzilla.redhat.com/1096443
+---
+ src/main.c      | 28 ++++++++++++++--------------
+ src/open-funs.c | 38 +++++++++++++++++++-------------------
+ src/rename.c    | 22 +++++++++++-----------
+ src/unlink.c    | 18 +++++++++---------
+ 4 files changed, 53 insertions(+), 53 deletions(-)
+
+diff --git a/src/main.c b/src/main.c
+index 75f7c51..1bc2413 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -53,7 +53,7 @@ static char default_relative_trash_can[] = TRASH_CAN;
+ 
+ static char default_relative_trash_system_root[] = TRASH_SYSTEM_ROOT;
+ 
+-/* calling init() is the first thing every wrapper function does. It is used
++/* calling libtrash_init() is the first thing every wrapper function does. It is used
+  to gather necessary user information and preferences (if any),
+  perform some tests and "turn off" libtrash if it finds any problems.
+  This is done by setting the variable general_failure, the value of
+@@ -68,10 +68,10 @@ static char default_relative_trash_system_root[] = TRASH_SYSTEM_ROOT;
+  _init() collected had already become out of date (e.g., processes
+  which change UIDs (<-Samba), etc). */
+ 
+-/* init() is passed a pointer to a cfg structure (defined in trash.h), which it
++/* libtrash_init() is passed a pointer to a cfg structure (defined in trash.h), which it
+  * uses to communicate to the wrapper which called it the current configuration settings: */
+ 
+-void init(config *cfg)
++void libtrash_init(config *cfg)
+ {
+ 
+    /* Variables: */
+@@ -177,7 +177,7 @@ void init(config *cfg)
+ 
+    cfg->absolute_trash_system_root = NULL;
+ 
+-   /* (The following paths need only be accessed by init() and get_config_from_file().) */
++   /* (The following paths need only be accessed by libtrash_init() and get_config_from_file().) */
+ 
+    /* Name of directory under the user's home directory in which we store deleted files (i.e., "trash can"): */
+ 
+@@ -208,7 +208,7 @@ void init(config *cfg)
+ 
+    cfg->intercept_open   = INTERCEPT_OPEN;
+ 
+-   /* Used by init() to signal to the called functions that libtrash is disabled either at the request of the
++   /* Used by libtrash_init() to signal to the called functions that libtrash is disabled either at the request of the
+     user or because a serious error occurred: */
+ 
+    cfg->libtrash_off = NO;
+@@ -303,8 +303,8 @@ void init(config *cfg)
+      }
+ 
+    /* (All the configuration variables are by now set. The allocated memory which needs to be free()d will
+-    be deallocated in fini(), except for relative_trash_(can|system_root), which will be free()d before
+-    this function (init()) returns.) */
++    be deallocated in libtrash_fini(), except for relative_trash_(can|system_root), which will be free()d before
++    this function (libtrash_init()) returns.) */
+ 
+ #ifdef DEBUG
+    fprintf(stderr,
+@@ -374,7 +374,7 @@ void init(config *cfg)
+    /* Information which the functions we will be overriding need: home, absolute_trash_can and
+     * possibly absolute_trash_system_root. */
+ 
+-   /* This memory will be free()d in fini() : */
++   /* This memory will be free()d in libtrash_fini() : */
+ 
+    cfg->home = malloc(strlen(userinfo->pw_dir) + 1);
+ 
+@@ -390,7 +390,7 @@ void init(config *cfg)
+ #ifdef DEBUG
+ 	fprintf(stderr, "Unable to allocate sufficient memory.\ngeneral_failure set.\n");
+ #endif
+-	/* Free any successfully allocated memory and point the respective pointer to NULL, so that fini() doesn't
++	/* Free any successfully allocated memory and point the respective pointer to NULL, so that libtrash_fini() doesn't
+ 	 try to free() that memory again: */
+ 
+ 	if (cfg->home)
+@@ -411,7 +411,7 @@ void init(config *cfg)
+ 	     cfg->absolute_trash_system_root = NULL;
+ 	  }
+ 
+-	/* Free memory previously allocated inside get_config_from_files() (no need to point it to NULL since fini() never
++	/* Free memory previously allocated inside get_config_from_files() (no need to point it to NULL since libtrash_fini() never
+ 	 tries to free() the memory these pointers point at): */
+ 
+ 	if (cfg->relative_trash_can != default_relative_trash_can)
+@@ -472,17 +472,17 @@ void init(config *cfg)
+ 	return;
+      }
+ 
+-   /* We know everything we need to know. init() is done. */
++   /* We know everything we need to know. libtrash_init() is done. */
+ 
+    return;
+ }
+ 
+ /* -------------------------------  */
+ 
+-/* Just like init(), this function is always invoked by the wrapper functions before quitting. Its
++/* Just like libtrash_init(), this function is always invoked by the wrapper functions before quitting. Its
+  only task is freeing malloc()ed memory: */
+ 
+-void fini(config *cfg)
++void libtrash_fini(config *cfg)
+ {
+ 
+    /* If libtrash is disabled and the user wishes to be informed, tell him about it: */
+@@ -526,7 +526,7 @@ void fini(config *cfg)
+      free(cfg->ignore_re);
+ 
+    /* DON'T free() relative_trash_(can|system_root)! The memory they point to has already been free()d by
+-    * init() before returning. */
++    * libtrash_init() before returning. */
+ 
+    return;
+ }
+diff --git a/src/open-funs.c b/src/open-funs.c
+index 90255b8..4d58458 100644
+--- a/src/open-funs.c
++++ b/src/open-funs.c
+@@ -452,7 +452,7 @@ int openat64(int dirfd, const char *arg_pathname, int flags, ...)
+ 	      (!error && !S_ISREG(file_stat.st_mode) && !S_ISLNK(file_stat.st_mode)) ||               \
+ 	      (!error && (function == OPEN || function == OPEN64) && (flags & O_NOFOLLOW) && S_ISLNK(file_stat.st_mode) ) ) \
+ 	{                                                                                             \
+-	   fini(&cfg);                                                                                \
++	   libtrash_fini(&cfg);                                                                       \
+ 	   RETURN_REAL_FUNCTION();                                                                    \
+ 	}                                                                                             \
+    }
+@@ -559,14 +559,14 @@ static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
+    
+    config cfg;
+    
+-   /* This function is different from unlink() and rename(), because it gets invoked by glibc functions called by init().
+-    * In order to avoid an infinite loop, we mustn't call init() in those situations, but rather invoke the real open
++   /* This function is different from unlink() and rename(), because it gets invoked by glibc functions called by libtrash_init().
++    * In order to avoid an infinite loop, we mustn't call libtrash_init() in those situations, but rather invoke the real open
+     * function. For that reason, this function needs to get a pointer to the "real function" it is playing all by itself
+-    * (that is one of the jobs init() does for the other functions).
+-    * How does this function avoid calling init() when it has been called by one of the glibc functions called by init()?
+-    * Fortunately, those functions only need to open files in read-only mode, so we can simply quit before calling init()
++    * (that is one of the jobs libtrash_init() does for the other functions).
++    * How does this function avoid calling libtrash_init() when it has been called by one of the glibc functions called by libtrash_init()?
++    * Fortunately, those functions only need to open files in read-only mode, so we can simply quit before calling libtrash_init()
+     * if we were asked to open a file in read-mode, thereby avoiding this problem. If, in the future, the glibc functions
+-    * called by init need to open files in write-mode libtrash in its current state will become unusable. I really can't
++    * called by libtrash_init need to open files in write-mode libtrash in its current state will become unusable. I really can't
+     * think of a better (and thread-safe) solution.
+     */
+    
+@@ -598,14 +598,14 @@ static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
+ 	fprintf(stderr, "Passing request to the real %s because the arguments we were passed don't specify "
+ 		"write-mode with orders to truncate existing files (or we have a NULL file name).\n", function_name);
+ #endif
+-	RETURN_REAL_FUNCTION(); /* we don't need to call fini() here. */
++	RETURN_REAL_FUNCTION(); /* we don't need to call libtrash_fini() here. */
+      }
+    
+-   /* First we call init(), which will set the configuration variables: */
++   /* First we call libtrash_init(), which will set the configuration variables: */
+    
+-   init(&cfg);
++   libtrash_init(&cfg);
+    
+-   /* From this point on, we always call fini() before quittting. */
++   /* From this point on, we always call libtrash_fini() before quittting. */
+    
+    /* Is cfg.libtrash_off set to true or cfg.intercept_(real_function) set to false? If so, just invoke the real function: */
+    
+@@ -614,7 +614,7 @@ static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
+ #ifdef DEBUG
+ 	fprintf(stderr, "Passing request to the real function because libtrash_off = true or intercept_%s = false.\n", function_name);
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	RETURN_REAL_FUNCTION();
+      }
+    
+@@ -625,7 +625,7 @@ static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
+ #ifdef DEBUG
+ 	fprintf(stderr, "Invoking %s_handle_error() because general_failure is set.\n", function_name);
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	DO_HANDLE_ERROR();
+      }
+    
+@@ -638,7 +638,7 @@ static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
+    fprintf(stderr, "Doesn't file %s exist?...\n", path);
+ #endif
+    
+-   TEST_FILE_EXISTENCE(); /* Invokes fini() by itself if it decides to return. */
++   TEST_FILE_EXISTENCE(); /* Invokes libtrash_fini() by itself if it decides to return. */
+    
+ #ifdef DEBUG
+    fprintf(stderr, "It does exist.\n");
+@@ -658,7 +658,7 @@ static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
+ #ifdef DEBUG
+ 	fprintf(stderr, "Unable to build absolute_path\nInvoking DO_HANDLE_ERROR() inside %s.\n", function_name);
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	
+ 	DO_HANDLE_ERROR();
+      }
+@@ -684,7 +684,7 @@ static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
+ 	
+ 	free(absolute_path);
+ 	
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	
+ 	RETURN_REAL_FUNCTION();
+ 	
+@@ -699,7 +699,7 @@ static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
+ 	
+ 	free(absolute_path);
+ 	
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	
+ 	RETURN_FUNCTION_ERROR(EACCES); /* setting errno to EACCES so that the caller interprets this error as being due to
+ 					* "insufficient permissions" */
+@@ -726,7 +726,7 @@ static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
+ #ifdef DEBUG
+ 	     fprintf(stderr, "graft_file() failed, %s() invoking DO_HANDLE_ERROR().\n", function_name);
+ #endif
+-	     fini(&cfg);
++	     libtrash_fini(&cfg);
+ 	     
+ 	     DO_HANDLE_ERROR();
+ 	  }
+@@ -740,7 +740,7 @@ static FdOrFp do_fopen_or_freopen_or_open(int function, const char *path, ...)
+ 	     
+ 	     DO_OPEN_SPECIFIC_PREPARATION();
+ 	     
+-	     fini(&cfg);
++	     libtrash_fini(&cfg);
+ 	     RETURN_REAL_FUNCTION();
+ 	  }
+ 	
+diff --git a/src/rename.c b/src/rename.c
+index be5e122..e05799b 100644
+--- a/src/rename.c
++++ b/src/rename.c
+@@ -66,11 +66,11 @@ int rename(const char *oldpath, const char *newpath)
+ #endif
+    
+    
+-   /* First we call init(), which will set the configuration variables: */
++   /* First we call libtrash_init(), which will set the configuration variables: */
+    
+-   init(&cfg);
++   libtrash_init(&cfg);
+    
+-   /* We always call fini() before quitting. */
++   /* We always call libtrash_fini() before quitting. */
+    
+    /* If real_rename is unavailable, we must return -1 because there's nothing else we can do: */
+    
+@@ -81,7 +81,7 @@ int rename(const char *oldpath, const char *newpath)
+ #endif
+ 	errno = 0; /* we set errno to zero so that, if errno was previously set to some other value, it 
+ 		    doesn't confuse the caller. */
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return -1;
+      }
+    
+@@ -96,7 +96,7 @@ int rename(const char *oldpath, const char *newpath)
+ 	fprintf(stderr, "Passing request to rename(%s, %s) to the real rename() because libtrash_off = true or intercept_rename = false (OR: one of the args is NULL).\n", 
+ 		oldpath, newpath);
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return (*cfg.real_rename) (oldpath, newpath); /* real rename() sets errno. */
+      }
+    
+@@ -111,7 +111,7 @@ int rename(const char *oldpath, const char *newpath)
+ 	fprintf(stderr, "general_failure is set in rename(), invoking rename_handle_error().\n"
+ 		"in_case_of_failure has value %d.\n", cfg.in_case_of_failure);
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return rename_handle_error(oldpath, newpath, cfg.real_rename, cfg.in_case_of_failure); /* either the real rename() sets errno, or we return -1 and errno is 
+ 												* set to 0. */
+      }
+@@ -130,7 +130,7 @@ int rename(const char *oldpath, const char *newpath)
+ #ifdef DEBUG
+ 	fprintf(stderr, "newpath (%s) either doesn't exit, or is a special file (non-symlink) or is a directory.\nCalling the \"real\" rename().\n", newpath);
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return (*cfg.real_rename) (oldpath, newpath); /* errno set by real rename(). */
+      } 
+    
+@@ -158,7 +158,7 @@ int rename(const char *oldpath, const char *newpath)
+ #ifdef DEBUG
+ 	fprintf(stderr, "oldpath (%s) either  doesn't exist or is a directory.\nCalling the \"real\" rename().\n", oldpath);
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return (*cfg.real_rename) (oldpath, newpath); /* errno set by real rename() */
+      }
+    
+@@ -199,7 +199,7 @@ int rename(const char *oldpath, const char *newpath)
+ 	fprintf(stderr, "We don't have write-access to the dir which contains oldpath (%s).\n"
+ 		"Calling the \"real\" rename().\n", oldpath);
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return (*cfg.real_rename) (oldpath, newpath); /* errno set by real rename() */
+      }
+    
+@@ -224,7 +224,7 @@ int rename(const char *oldpath, const char *newpath)
+ #ifdef DEBUG
+ 	fprintf(stderr, "Unable to build absolute_newpath.\nInvoking rename_handle_error().\n");
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return rename_handle_error(oldpath, newpath, cfg.real_rename,
+ 				   cfg.in_case_of_failure); /* errno set either by the real rename() or set to 0 (just like the other
+ 							     * call to rename_handle_error() above). */
+@@ -338,7 +338,7 @@ int rename(const char *oldpath, const char *newpath)
+    
+    free(absolute_newpath);
+    
+-   fini(&cfg);
++   libtrash_fini(&cfg);
+    return retval; /* By now, errno has been set to a meaningful value in one of the cases above. */
+ }
+ 
+diff --git a/src/unlink.c b/src/unlink.c
+index 418aae4..8c9216d 100644
+--- a/src/unlink.c
++++ b/src/unlink.c
+@@ -65,11 +65,11 @@ int unlink(const char *pathname)
+    fprintf(stderr, "\nEntering unlink().\n");
+ #endif
+    
+-   /* Run init(), which sets all the global variables: */
++   /* Run libtrash_init(), which sets all the global variables: */
+    
+-   init(&cfg);
++   libtrash_init(&cfg);
+    
+-   /* We always call fini() before quitting. */
++   /* We always call libtrash_fini() before quitting. */
+    
+    /* Isn't a pointer to GNU libc's unlink() available? In that case, there's nothing we can do: */
+    
+@@ -80,7 +80,7 @@ int unlink(const char *pathname)
+ #endif
+ 	errno = 0;
+ 	
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return -1; /* errno set to 0 in order to avoid confusing the caller. */
+      }
+    
+@@ -96,7 +96,7 @@ int unlink(const char *pathname)
+ 	else
+ 	  fprintf(stderr, "Passing request to unlink %s to the real unlink because libtrash_off = true or intercept_unlink = false.\n", pathname);
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return (*cfg.real_unlink) (pathname); /* real unlink() sets errno */
+      }
+    
+@@ -108,7 +108,7 @@ int unlink(const char *pathname)
+ 	fprintf(stderr, "general_failure is set in unlink(), invoking unlink_handle_error().\n"
+ 		"in_case_of_failure has value %d.\n", cfg.in_case_of_failure);
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return unlink_handle_error(pathname, cfg.real_unlink, cfg.in_case_of_failure); /* If in_case_of_failure is set to PROTECT, we return -1 with errno set to 0;
+ 											otherwise, the real unlink() sets errno. */
+      }
+@@ -126,7 +126,7 @@ int unlink(const char *pathname)
+ #ifdef DEBUG
+ 	fprintf(stderr, "%s either doesn't exit, or is a special file (non-symlink) or is a directory.\nCalling the \"real\" unlink().\n", pathname);
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return (*cfg.real_unlink) (pathname); /* real unlink() sets errno. */
+      }
+    
+@@ -162,7 +162,7 @@ int unlink(const char *pathname)
+ #ifdef DEBUG
+ 	fprintf(stderr, "Unable to build absolute_path.\nInvoking unlink_handle_error().\n");
+ #endif
+-	fini(&cfg);
++	libtrash_fini(&cfg);
+ 	return unlink_handle_error(pathname, cfg.real_unlink, cfg.in_case_of_failure); /* about errno: the same as in the other call to unlink_handle_error() above. */
+      }
+    
+@@ -273,7 +273,7 @@ int unlink(const char *pathname)
+    
+    free(absolute_path);
+    
+-   fini(&cfg);
++   libtrash_fini(&cfg);
+    return retval;
+ }
+ 
+-- 
+1.8.3.1
+
diff --git a/libtrash.spec b/libtrash.spec
index fb208cd..a09dcab 100644
--- a/libtrash.spec
+++ b/libtrash.spec
@@ -8,6 +8,11 @@ URL:           http://pages.stern.nyu.edu/~marriaga/software/libtrash
 Source:        http://pages.stern.nyu.edu/~marriaga/software/libtrash/%{name}-%{version}.tgz
 Patch0:        libtrash-3.2-defaults.patch
 Patch1:        libtrash-3.2-makefile.patch
+
+# rename init/fini to libtrash_init/libtrash_fini in order to avoid symbol
+# clashes when loading audacious plug-ins (#1096443)
+Patch2:        libtrash-3.2-bz1096443.patch
+
 BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: perl, python
 
@@ -29,8 +34,9 @@ implements a trash can under GNU/Linux.
 
 %prep
 %setup -q
-%patch0 -p1 -b .defaults
-%patch1 -p1 -b .makefile
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
 
 %build
 # -D_REENTRANT: keep up to date with src/Makefile
@@ -65,6 +71,9 @@ rm -rf $RPM_BUILD_ROOT
 %doc README TODO COPYING CHANGE.LOG config.txt 
 
 %changelog
+* Mon May 12 2014 Kamil Dudka <kdudka at redhat.com> - 3.2-14
+- avoid symbol clashes when loading audacious plug-ins (#1096443)
+
 * Sat Aug 03 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 3.2-13
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
 


More information about the scm-commits mailing list