Bug#646031: theunarchiver: creates $HOME/GNUstep/Library directory

2013-07-28 Thread Michael Gold
On Wed, Jan 11, 2012 at 16:25:07 +0100, Jakub Wilk wrote:
 When I unpack RAR archives with unar, it creates
 $HOME/GNUstep/Library directory:
...
 I took another approach to work around this problem: I created a
 LD_PRELOAD'able library that overrides the mkdir() function.
 
 I think the same effect could be achieved by linking antignustep.o
 directly into the unar binary. (Though I know absolutely nothing
 about Objective-C, so I could be wrong.)

FYI, you can change the path by setting GNUSTEP_USER_DIR_LIBRARY in
~/.GNUstep.conf.  A setting like
  GNUSTEP_USER_DIR_LIBRARY=/var/empty/.GNUstep/Library
will make the directory go away, without any complaints from unar.

I'm attaching my .GNUstep.conf to show the possible directories and
their default layout (replacing ~/GNUstep with /var/empty/.GNUstep).

-- Michael
# Important: settings in the User should normally be relative paths,
# and will be interpreted as relative to the user's directory.  This
# allows each user to have their own domain to install things.  You
# can set them to be absolute, mostly if you want to disable them
# by setting them equal to the ones in the Network domain.

GNUSTEP_USER_DIR=/var/empty/.GNUstep
GNUSTEP_USER_DEFAULTS_DIR=/var/empty/.GNUstep/Defaults
GNUSTEP_USER_DIR_APPS=/var/empty/.GNUstep/Applications
GNUSTEP_USER_DIR_ADMIN_APPS=/var/empty/.GNUstep/Applications/Admin
GNUSTEP_USER_DIR_WEB_APPS=/var/empty/.GNUstep/WebApplications
GNUSTEP_USER_DIR_TOOLS=/var/empty/.GNUstep/Tools
GNUSTEP_USER_DIR_ADMIN_TOOLS=/var/empty/.GNUstep/Tools/Admin
GNUSTEP_USER_DIR_LIBRARY=/var/empty/.GNUstep/Library
GNUSTEP_USER_DIR_HEADERS=/var/empty/.GNUstep/Library/Headers
GNUSTEP_USER_DIR_LIBRARIES=/var/empty/.GNUstep/Library/Libraries
GNUSTEP_USER_DIR_DOC=/var/empty/.GNUstep/Library/Documentation
GNUSTEP_USER_DIR_DOC_MAN=/var/empty/.GNUstep/Library/Documentation/man
GNUSTEP_USER_DIR_DOC_INFO=/var/empty/.GNUstep/Library/Documentation/info


signature.asc
Description: Digital signature


Bug#646031: theunarchiver: creates $HOME/GNUstep/Library directory

2012-01-11 Thread Jakub Wilk

* Yavor Doganov ya...@gnu.org, 2011-10-21, 13:07:

Package: theunarchiver



When I unpack RAR archives with unar, it creates
$HOME/GNUstep/Library directory:



I wish it didn't clutter my home directory with useless directories...


This directory is not useless, and gnustep-base makes sure to create it 
as many methods rely on its existence.


Right. I meant that it's useless for me, because unar is the only 
GNUstep software I use, so the directory is always empty.



The attached patch should do the desired cleanup, but:

- Please test extensively, it is potentially dangerous.
- There could be a race condition in the unlikely case that the same 
user is running `unar' and another GNUstep program simultaneously.


I took another approach to work around this problem: I created a 
LD_PRELOAD'able library that overrides the mkdir() function.


I think the same effect could be achieved by linking antignustep.o 
directly into the unar binary. (Though I know absolutely nothing about 
Objective-C, so I could be wrong.)


--
Jakub Wilk
/*
 * Copyright © 2011 Jakub Wilk jw...@debian.org
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the “Software”), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include dlfcn.h
#include errno.h
#include pwd.h
#include string.h
#include sys/stat.h
#include sys/types.h
#include unistd.h

static int done;
static int (*original_mkdir)(const char *, mode_t);

int mkdir(const char *path, mode_t mode)
{
if (mode != 0777) {
done = 1;
return original_mkdir(path, mode);
}
if (!done) {
done = 1;
/* Don't allow creating the very first directory (which should be
 * $HOME/GNUstep), but only if the call passes sanity checks.
 */
if (mode == 0777) {
struct passwd* pw = getpwuid(getuid());
if (pw == NULL || pw-pw_dir)
return -1;
size_t home_len = strlen(pw-pw_dir);
if (strncmp(path, pw-pw_dir, home_len) == 0  strcmp(path + home_len, /GNUstep) == 0) {
errno = EACCES;
return -1;
}
}
}
if (!original_mkdir) {
original_mkdir = dlsym(RTLD_NEXT, mkdir);
if (!original_mkdir) {
errno = EINVAL;
return -1;
}
}
return original_mkdir(path, mode);
}

/* vim:set ts=4 sw=4 et:*/


Bug#643305: Bug#646031: theunarchiver: creates $HOME/GNUstep/Library directory

2011-10-21 Thread Yavor Doganov
tags 643305 + wontfix
notforwarded 643305
forwarded 646031 http://code.google.com/p/theunarchiver/issues/detail?id=397
tags 646031 + patch
thanks

On Thu, Oct 20, 2011 at 08:00:18PM +0200, Jakub Wilk wrote:
 Package: theunarchiver

 When I unpack RAR archives with unar, it creates
 $HOME/GNUstep/Library directory:

 I wish it didn't clutter my home directory with useless directories...

This directory is not useless, and gnustep-base makes sure to create
it as many methods rely on its existence.  In this case, unar is not
using it directly or accessing the defaults database, but it uses the
NSDate class, which needs to check the timezone upon initialization,
which in turn uses NSUserDefaults to retrieve any user-defined one,
etc, etc.

In theory, with some effort it could be possible to eradicate this
behaviour as it really smells like bad design, but right now I have
more important problems at hand than having a discussion with upstream
regarding this minor issue.

If you wonder why the directory is not hidden, it is because GNUstep
software is installed there in the USER domain.

The attached patch should do the desired cleanup, but:

- Please test extensively, it is potentially dangerous.
- There could be a race condition in the unlikely case that the same
  user is running `unar' and another GNUstep program simultaneously.
- It uses a GNUstep-specific function, so should be wrapped in
  appropriate conditionals (#ifdef GNUSTEP...) if the same code is
  compiled/run on Muck OS X.
--- theunarchiver-2.7.1.orig/XADMaster/unar.m
+++ theunarchiver-2.7.1/XADMaster/unar.m
@@ -133,7 +133,23 @@ fileFraction:(double)fileprogress estima
 
 @end
 
-
+/* Helper function to delete ~/GNUstep if it is created as a side
+   effect of using unar.  */
+void
+cleanup (void)
+{
+  NSFileManager *mgr;
+  NSString *dir;
+  NSArray *paths;
+
+  mgr = [NSFileManager defaultManager];
+  dir = [GSDefaultsRootForUser (NSUserName ())
+			   stringByDeletingLastPathComponent];
+  paths = [mgr subpathsAtPath: dir];
+  if ([paths count] == 1
+   [[NSString pathWithComponents: paths] isEqualToString: @Library])
+[mgr removeFileAtPath: dir handler: nil];
+}
 
 
 int main(int argc,const char **argv)
@@ -278,6 +294,7 @@ int main(int argc,const char **argv)
 		[pool release];
 	}
 
+cleanup ();
 	[pool release];
 
 	return 0;


Bug#646031: theunarchiver: creates $HOME/GNUstep/Library directory

2011-10-20 Thread Jakub Wilk

Package: theunarchiver
Version: 2.7.1-4
Severity: minor

When I unpack RAR archives with unar, it creates $HOME/GNUstep/Library 
directory:


| $ rm -rf ~/GNUstep
| $ strace -e mkdir unar test.rar
| Extracting test.rar...
| mkdir(/home/jwilk/GNUstep, 0777)  = 0
| mkdir(/home/jwilk/GNUstep/Library, 0777) = 0
|   dummy (0)... OK.

I wish it didn't clutter my home directory with useless directories...


-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'experimental')
Architecture: i386 (x86_64)

Kernel: Linux 3.0.0-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages theunarchiver depends on:
ii  gnustep-base-runtime  1.22.1-1  
ii  libbz2-1.01.0.5-7   
ii  libc6 2.13-21   
ii  libgcc1   1:4.6.1-16
ii  libgnustep-base1.22   1.22.1-1  
ii  libicu44  4.4.2-2   
ii  libobjc3  4.6.1-16  
ii  libssl1.0.0   1.0.0e-2  
ii  libstdc++64.6.1-16  
ii  zlib1g1:1.2.5.dfsg-1


--
Jakub Wilk



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#646031: theunarchiver: creates $HOME/GNUstep/Library directory

2011-10-20 Thread Matt Kraai
block 646031 by 643305
thanks

On Thu, Oct 20, 2011 at 08:00:18PM +0200, Jakub Wilk wrote:
 When I unpack RAR archives with unar, it creates
 $HOME/GNUstep/Library directory:
 
 | $ rm -rf ~/GNUstep
 | $ strace -e mkdir unar test.rar
 | Extracting test.rar...
 | mkdir(/home/jwilk/GNUstep, 0777)  = 0
 | mkdir(/home/jwilk/GNUstep/Library, 0777) = 0
 |   dummy (0)... OK.
 
 I wish it didn't clutter my home directory with useless directories...

Thanks for reporting this issue.  It's actually been reported before
and reassigned to libgnustep-base1.22, since that's the package that
creates the directories.  To discourage further reports, I'm marking
this bug as blocked by that one.

-- 
Matt Kraai
https://ftbfs.org/kraai



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org