-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ShareMounter and missing KerbUtil filet
- Loading branch information
Showing
6 changed files
with
181 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Header.h | ||
// NoMAD | ||
// | ||
// Created by Joel Rennich on 4/26/16. | ||
// Copyright © 2016 Orchard & Grove Inc. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <GSS/GSS.h> | ||
#import <Cocoa/Cocoa.h> | ||
#import <Security/Security.h> | ||
#import <DirectoryService/DirectoryService.h> | ||
#import <OpenDirectory/OpenDirectory.h> | ||
|
||
extern OSStatus SecKeychainItemSetAccessWithPassword(SecKeychainItemRef item, SecAccessRef access, UInt32 passLength, const void* password); | ||
|
||
@interface KerbUtil : NSObject | ||
@property (nonatomic, assign, readonly) BOOL finished; // observable | ||
|
||
- (void)getKerberosCredentials:(NSString *)password :(NSString *)userPrincipal completion:(void(^)(NSString *))callback; | ||
- (NSString *)getKerbCredentials:(NSString *)password :(NSString *)userPrincipal; | ||
- (void)changeKerberosPassword:(NSString *)oldPassword :(NSString *)newPassword :(NSString *)userPrincipal completion:(void(^)(NSString *))callback; | ||
- (NSString *)changeKerbPassword:(NSString *)oldPassword :(NSString *)newPassword :(NSString *)userPrincipal; | ||
- (int)checkPassword:(NSString *)myPassword; | ||
- (int)changeKeychainPassword:(NSString *)oldPassword :(NSString *)newPassword; | ||
- (OSStatus)resetKeychain:(NSString *)password; | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// | ||
// ShareMounter.swift | ||
// NoMAD | ||
// | ||
// Created by Joel Rennich on 8/29/16. | ||
// Copyright © 2016 Trusource Labs. All rights reserved. | ||
// | ||
|
||
// mad props to Kyle Crawshaw | ||
// since much of this is cribbed from Share Mounter | ||
|
||
import Foundation | ||
import NetFS | ||
|
||
struct share_info { | ||
var groups: [String] | ||
var share_url: String | ||
var title: String | ||
} | ||
|
||
class ShareMounter { | ||
|
||
var all_shares = [share_info]() | ||
let ws = NSWorkspace.init() | ||
var prefs: [String] | ||
|
||
init() { | ||
// read in the preference files | ||
|
||
|
||
if UserDefaults.standard.bool(forKey: PrefKeys.showHome.rawValue) { | ||
//NSLog("Looking for ShareMounter files") | ||
//prefs = try! ["/Library/Preferences/ShareMounter.plist", NSHomeDirectory() + "/Library/Preferences/ShareMounter.plist"] | ||
/* | ||
do { | ||
try! getShares() | ||
} | ||
} else { | ||
prefs = [""] | ||
*/ | ||
} | ||
prefs = [""] | ||
} | ||
|
||
func mount() { | ||
|
||
let myGroups = UserDefaults.standard.array(forKey: PrefKeys.groups.rawValue) | ||
|
||
for share in all_shares { | ||
for group in myGroups! { | ||
if share.groups.contains(group as! String) { | ||
// time to mount | ||
NSLog("Attempting to mount: " + share.share_url) | ||
asyncMountShare(share.share_url) | ||
break | ||
} | ||
} | ||
} | ||
} | ||
|
||
func getShares() { | ||
for place in prefs { | ||
let myDictionary = NSDictionary.init(contentsOfFile: place) | ||
|
||
if myDictionary != nil { | ||
let shares = (myDictionary?.object(forKey: "network_shares"))! as! [AnyObject] | ||
|
||
for i in shares { | ||
let currentShare = share_info(groups: i.object(forKey: "groups")! as! Array, share_url: i.object(forKey: "share_url")! as! String, title: i.object(forKey: "title")! as! String) | ||
all_shares.append(currentShare) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func openOptionsDict() -> CFMutableDictionary { | ||
let dict = NSMutableDictionary() | ||
dict[kNAUIOptionKey] = kNAUIOptionNoUI | ||
dict[kNetFSUseGuestKey] = true | ||
return dict | ||
} | ||
|
||
func mountOptionsDict() -> CFMutableDictionary { | ||
let dict = NSMutableDictionary() | ||
//dict[kNetFSMountFlagsKey] = Int(MNT_DONTBROWSE) | ||
return dict | ||
} | ||
|
||
func asyncMountShare(_ serverAddress: String) { | ||
|
||
let escapedAddress = serverAddress.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) | ||
let shareAddress = URL(string: escapedAddress!)! | ||
|
||
// TODO: ensure the URL is reachable before attempting to mount | ||
|
||
//let open_options : CFMutableDictionary = openOptionsDict() | ||
let mount_options : CFMutableDictionary = mountOptionsDict() | ||
|
||
var requestID: AsyncRequestID? = nil | ||
let queue = DispatchQueue.main | ||
|
||
if let userPrinc = UserDefaults.standard.string(forKey: PrefKeys.userPrincipal.rawValue){ | ||
NetFSMountURLAsync(shareAddress as CFURL, | ||
nil, | ||
userPrinc as CFString, | ||
nil, | ||
nil, | ||
mount_options, | ||
&requestID, | ||
queue) | ||
{(stat:Int32, requestID:AsyncRequestID?, mountpoints:CFArray?) -> Void in | ||
if let mountpoints = mountpoints as? Array<String>{ | ||
myLogger.logit(.base, message: "Mounted \(mountpoints)") | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
func getNetworkShares() { | ||
let fm = FileManager.default | ||
|
||
let myShares = fm.mountedVolumeURLs(includingResourceValuesForKeys: nil, options: FileManager.VolumeEnumerationOptions.skipHiddenVolumes) | ||
|
||
for share in myShares! { | ||
|
||
var myDes: NSString? = nil | ||
var myType: NSString? = nil | ||
|
||
ws.getFileSystemInfo(forPath: share.path, isRemovable: nil, isWritable: nil, isUnmountable: nil, description: &myDes, type: &myType) | ||
print(myType!) | ||
if myType! == "smbfs" { | ||
print("Volume: " + share.path + " is an SMB network volume.") | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,6 +159,7 @@ | |
76BEF8002872A3030013E2A1 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 76BEF7FE2872A3030013E2A1 /* [email protected] */; }; | ||
76BEF8012872A3030013E2A1 /* loginwindow.png in Resources */ = {isa = PBXBuildFile; fileRef = 76BEF7FF2872A3030013E2A1 /* loginwindow.png */; }; | ||
76C0840B2A9A311E008039FA /* ControlsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 76C084092A9A2635008039FA /* ControlsViewController.xib */; }; | ||
76C4ACBF2B3D0F8D003B3605 /* ShareMounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76C4ACBE2B3D0F8D003B3605 /* ShareMounter.swift */; }; | ||
76C4BAB02B353A30007B2C57 /* KlistUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7657DEC82B350606003A23DB /* KlistUtil.swift */; }; | ||
76C4BAB12B353A3A007B2C57 /* DNSResolver.m in Sources */ = {isa = PBXBuildFile; fileRef = 7657DEBE2B3505A3003A23DB /* DNSResolver.m */; }; | ||
76C4BAB32B353AD7007B2C57 /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 76C4BAB22B353AD7007B2C57 /* libresolv.tbd */; }; | ||
|
@@ -439,6 +440,7 @@ | |
76BEF7FE2872A3030013E2A1 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; }; | ||
76BEF7FF2872A3030013E2A1 /* loginwindow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = loginwindow.png; sourceTree = "<group>"; }; | ||
76C084092A9A2635008039FA /* ControlsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ControlsViewController.xib; sourceTree = "<group>"; }; | ||
76C4ACBE2B3D0F8D003B3605 /* ShareMounter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShareMounter.swift; sourceTree = "<group>"; }; | ||
76C4BAB22B353AD7007B2C57 /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; }; | ||
76C4BAB52B353AF7007B2C57 /* Kerberos.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Kerberos.framework; path = System/Library/Frameworks/Kerberos.framework; sourceTree = SDKROOT; }; | ||
76C4BABA2B353B4B007B2C57 /* KerbUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KerbUtil.m; sourceTree = "<group>"; }; | ||
|
@@ -759,6 +761,7 @@ | |
76EE069127FD1D00009E0F3A = { | ||
isa = PBXGroup; | ||
children = ( | ||
76C4ACBE2B3D0F8D003B3605 /* ShareMounter.swift */, | ||
76C4BAB92B353B3F007B2C57 /* NoMAD */, | ||
760148A82B23639D00E119A2 /* NSBundle+FindBundlePath.swift */, | ||
7614D03B2B181A5D006EAF36 /* icon_128x128.png */, | ||
|
@@ -1303,6 +1306,7 @@ | |
7657DEAF2B3503BF003A23DB /* SessionManager.swift in Sources */, | ||
7681FEC52A4C8B9000F91CD1 /* AboutWindowController.swift in Sources */, | ||
768633D92AFC4908004065E5 /* WifiManager.swift in Sources */, | ||
76C4ACBF2B3D0F8D003B3605 /* ShareMounter.swift in Sources */, | ||
7657DED92B351B5B003A23DB /* UNIXUtilities.swift in Sources */, | ||
76E74DCF2B3902F0004C6429 /* XCredsMechanismProtocol.swift in Sources */, | ||
76EE06C227FD1F50009E0F3A /* MainMenu.swift in Sources */, | ||
|
@@ -1410,7 +1414,7 @@ | |
buildSettings = { | ||
CODE_SIGN_STYLE = Automatic; | ||
COMBINE_HIDPI_IMAGES = YES; | ||
CURRENT_PROJECT_VERSION = 6174; | ||
CURRENT_PROJECT_VERSION = 6175; | ||
DEFINES_MODULE = YES; | ||
DEVELOPMENT_TEAM = UXP6YEHSPW; | ||
FRAMEWORK_SEARCH_PATHS = ( | ||
|
@@ -1447,7 +1451,7 @@ | |
buildSettings = { | ||
CODE_SIGN_STYLE = Automatic; | ||
COMBINE_HIDPI_IMAGES = YES; | ||
CURRENT_PROJECT_VERSION = 6174; | ||
CURRENT_PROJECT_VERSION = 6175; | ||
DEFINES_MODULE = YES; | ||
DEVELOPMENT_TEAM = UXP6YEHSPW; | ||
FRAMEWORK_SEARCH_PATHS = ( | ||
|
@@ -1568,7 +1572,7 @@ | |
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements"; | ||
CODE_SIGN_STYLE = Automatic; | ||
COMBINE_HIDPI_IMAGES = YES; | ||
CURRENT_PROJECT_VERSION = 6174; | ||
CURRENT_PROJECT_VERSION = 6175; | ||
DEVELOPMENT_TEAM = UXP6YEHSPW; | ||
ENABLE_HARDENED_RUNTIME = YES; | ||
FRAMEWORK_SEARCH_PATHS = ( | ||
|
@@ -1605,7 +1609,7 @@ | |
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements"; | ||
CODE_SIGN_STYLE = Automatic; | ||
COMBINE_HIDPI_IMAGES = YES; | ||
CURRENT_PROJECT_VERSION = 6174; | ||
CURRENT_PROJECT_VERSION = 6175; | ||
DEVELOPMENT_TEAM = UXP6YEHSPW; | ||
ENABLE_HARDENED_RUNTIME = YES; | ||
FRAMEWORK_SEARCH_PATHS = ( | ||
|
@@ -1755,7 +1759,7 @@ | |
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements; | ||
CODE_SIGN_STYLE = Automatic; | ||
COMBINE_HIDPI_IMAGES = YES; | ||
CURRENT_PROJECT_VERSION = 6174; | ||
CURRENT_PROJECT_VERSION = 6175; | ||
DEVELOPMENT_TEAM = UXP6YEHSPW; | ||
ENABLE_HARDENED_RUNTIME = YES; | ||
FRAMEWORK_SEARCH_PATHS = ( | ||
|
@@ -1797,7 +1801,7 @@ | |
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements; | ||
CODE_SIGN_STYLE = Automatic; | ||
COMBINE_HIDPI_IMAGES = YES; | ||
CURRENT_PROJECT_VERSION = 6174; | ||
CURRENT_PROJECT_VERSION = 6175; | ||
DEVELOPMENT_TEAM = UXP6YEHSPW; | ||
ENABLE_HARDENED_RUNTIME = YES; | ||
FRAMEWORK_SEARCH_PATHS = ( | ||
|
Binary file modified
BIN
+1.35 KB
(100%)
...deproj/project.xcworkspace/xcuserdata/tperfitt.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters