Strip newline characters from user password files

Makes it easier to create those files with a regular editor.
pull/10/head
Jean Raby 2013-02-20 10:50:58 -05:00
parent fa5e99d58d
commit 7d65d808f6
1 changed files with 5 additions and 2 deletions

View File

@ -20,6 +20,7 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#import <Foundation/NSCharacterSet.h>
#import <Foundation/NSData.h> #import <Foundation/NSData.h>
#import <Foundation/NSDictionary.h> #import <Foundation/NSDictionary.h>
#import <Foundation/NSMapTable.h> #import <Foundation/NSMapTable.h>
@ -107,15 +108,17 @@ static NSMapTable *contextsTable = nil;
password = nil; password = nil;
path = [NSString stringWithFormat: SAMBA_PRIVATE_DIR path = [NSString stringWithFormat: SAMBA_PRIVATE_DIR
@"/mapistore/%@/password", newUsername]; @"/mapistore/%@/password", newUsername];
content = [NSData dataWithContentsOfFile: path]; content = [NSData dataWithContentsOfFile: path];
if (content) if (content)
{ {
password = [[NSString alloc] initWithData: content password = [[NSString alloc] initWithData: content
encoding: NSUTF8StringEncoding]; encoding: NSUTF8StringEncoding];
[password autorelease]; [password autorelease];
password = [password stringByTrimmingCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString: @"\r\n"]];
} }
return password; return password;