Skip to content

Commit

Permalink
Merge branch 'release/1.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ygini committed Jan 23, 2019
2 parents f591928 + 116fdd4 commit e165227
Show file tree
Hide file tree
Showing 18 changed files with 129 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
*.pkg

# CocoaPods
#
Expand Down
14 changes: 14 additions & 0 deletions example/EnrollMe/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Enroll Me
---
##### Author: [Yoann Gini](https://www.github.com/ygini)

### Description:
This initial settings must be used with additional [Hello IT script made to trigger the DEP enrollment popup](https://github.com/ygini/ygini-scripts-macos/tree/master/EnrollMe).

Main idea would be to replace your current Hello IT settings with a single item presenting the red state and asking for enrollment.

The user clicking on the Hello IT item will be admin for few seconds, just the time for macOS to show the enrollment notification.

Once the notification is shown, the user does not need to be admin to continue the process.

Non-DEP scenario isn't supported and providing help text to the user isn't handled. In this scenario, you are supposed to send an e-mail or something to the end users, explaining what they are supposed to do.
25 changes: 25 additions & 0 deletions example/EnrollMe/com.github.ygini.Hello-IT.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>content</key>
<array>
<dict>
<key>functionIdentifier</key>
<string>public.script.item</string>
<key>settings</key>
<dict>
<key>title</key>
<dict>
<key>fr</key>
<string>Enrôler votre Mac</string>
<key>en</key>
<string>Enroll this Mac</string>
</dict>
<key>script</key>
<string>com.github.ygini.enrollme.hello-it.sh</string>
</dict>
</dict>
</array>
</dict>
</plist>
16 changes: 16 additions & 0 deletions example/EnrollMe/createPackage.command
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

SRC_DIR="$(dirname ${BASH_SOURCE[0]})"
PKG_VERSION="$(date +%Y.%m.%d).1"

PKG_ROOT=$(mktemp -d)
echo "####### Create package"

mkdir -p "${PKG_ROOT}/Library/Preferences"
cp -r "${SRC_DIR}/com.github.ygini.Hello-IT.plist" "${PKG_ROOT}/Library/Preferences"

pkgbuild --root "${PKG_ROOT}" --identifier "com.github.ygini.enrollme.hello-it.prefs" --scripts "${SRC_DIR}/pkg_scripts" --version "${PKG_VERSION}" "${SRC_DIR}/HelloIT-EnrollMe-Prefs-${PKG_VERSION}.pkg"

rm -rf "${PKG_ROOT}"

exit 0
17 changes: 17 additions & 0 deletions example/EnrollMe/pkg_scripts/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

killall cfprefsd

while read shortname
do
uid=$(id -u "$shortname")

if [ -n "$uid" ]
then
/bin/launchctl asuser "$uid" /bin/launchctl unload /Library/LaunchAgents/com.github.ygini.hello-it.plist
/bin/launchctl asuser "$uid" /bin/launchctl remove com.github.ygini.hello-it
/bin/launchctl asuser "$uid" /bin/launchctl load /Library/LaunchAgents/com.github.ygini.hello-it.plist
fi
done < <(ps aux | grep "MacOS/[F]inder" | awk '{print $1}')

exit 0
2 changes: 1 addition & 1 deletion src/HITDevKit/HITDevKit/HITBasicPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (NSString*)localizedString:(id)dictionaryOrArray {

for (NSString *localIdentifier in @[
[[NSLocale currentLocale] localeIdentifier],
[[NSLocale currentLocale] languageCode],
[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode],
@"en"]) {
selectedValue = [dictionaryOrArray objectForKey:localIdentifier];
if (selectedValue) {
Expand Down
2 changes: 1 addition & 1 deletion src/HITDevKit/HITDevKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>288</string>
<string>304</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Yoann Gini (Open Source Project). All rights reserved.</string>
<key>NSPrincipalClass</key>
Expand Down
17 changes: 16 additions & 1 deletion src/Hello IT.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@
remoteGlobalIDString = F83294A41F773076009DA574;
remoteInfo = ADPass;
};
F8CF084221A729190070C049 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F8D61B8520C8731A00DE2453 /* CachetHQ.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = F811AD2F2149A07E00BD15AD;
remoteInfo = CachetHQIncidents;
};
F8D61B8920C8731A00DE2453 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F8D61B8520C8731A00DE2453 /* CachetHQ.xcodeproj */;
Expand Down Expand Up @@ -511,6 +518,7 @@
isa = PBXGroup;
children = (
F8D61B8A20C8731A00DE2453 /* CachetHQComponent.hitp */,
F8CF084321A729190070C049 /* CachetHQIncidents.hitp */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -730,6 +738,13 @@
remoteRef = F83294B21F773078009DA574 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
F8CF084321A729190070C049 /* CachetHQIncidents.hitp */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = CachetHQIncidents.hitp;
remoteRef = F8CF084221A729190070C049 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
F8D61B8A20C8731A00DE2453 /* CachetHQComponent.hitp */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
Expand Down Expand Up @@ -791,7 +806,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -o errexit\nset -o nounset\n\nVERSION=$(git rev-list HEAD | wc -l)\n\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $VERSION\" \"${INFOPLIST_FILE}\"";
shellScript = "set -o errexit\nset -o nounset\n\nVERSION=$(git rev-list HEAD | wc -l)\n\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $VERSION\" \"${INFOPLIST_FILE}\"\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
4 changes: 2 additions & 2 deletions src/Hello IT/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.1</string>
<string>1.4.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>288</string>
<string>304</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
47 changes: 28 additions & 19 deletions src/Plugins/ADPass/ADPass/HITPADPass.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,13 @@ - (void)periodicAction:(NSTimer *)timer {
asl_log(NULL, NULL, ASL_LEVEL_INFO, "No AD Password expiry date found, hidding menu item.");
self.menuItem.hidden = YES;
}

}

- (void)updateTitle {
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay fromDate:[NSDate date] toDate:self.passwordExpiryDate options:0];
long daysBeforeExpiry = (long)[components day];

if (daysBeforeExpiry == 10522613) {
self.menuItem.title = self.neverExpireInfo;
} else {
self.menuItem.title = [NSString stringWithFormat:self.willExpireFormat, daysBeforeExpiry];
}
self.menuItem.title = [NSString stringWithFormat:self.willExpireFormat, daysBeforeExpiry];

if (self.lastADRequestSucceded) {
self.menuItem.target = self;
Expand Down Expand Up @@ -213,24 +208,38 @@ - (void)getPasswordExpiryDate {
// Thank you Microsoft to use Jan 1, 1601 at 00:00 UTC as reference date…
if (expiryTime) {
asl_log(NULL, NULL, ASL_LEVEL_INFO, "AD Password expiry date requested with success.");
NSDateComponents *adRefenreceDateComponents = [[NSDateComponents alloc] init];
[adRefenreceDateComponents setDay:1];
[adRefenreceDateComponents setMonth:1];
[adRefenreceDateComponents setYear:1601];
[adRefenreceDateComponents setEra:1];

NSDate *adRefenreceDate = [[NSCalendar calendarWithIdentifier:NSCalendarIdentifierISO8601] dateFromComponents:adRefenreceDateComponents];
NSTimeInterval expiryTimeInterval = [expiryTime integerValue] / 10000000.0;
if ([expiryTime integerValue] == 0x7FFFFFFFFFFFFFFF) {
asl_log(NULL, NULL, ASL_LEVEL_INFO, "AD Password expiry date is mean no expiry.");
self.passwordExpiryDate = nil;
self.lastADRequestSucceded = YES;
[[NSUserDefaults standardUserDefaults] setInteger:-1 forKey:kHITPADPassExpiryTimeKey];
} else {
asl_log(NULL, NULL, ASL_LEVEL_INFO, "AD Password expiry date is a valid date.");


self.passwordExpiryDate = [NSDate dateWithTimeInterval:expiryTimeInterval sinceDate:adRefenreceDate];
self.lastADRequestSucceded = YES;

[[NSUserDefaults standardUserDefaults] setInteger:[self.passwordExpiryDate timeIntervalSince1970] forKey:kHITPADPassExpiryTimeKey];
NSDateComponents *adRefenreceDateComponents = [[NSDateComponents alloc] init];
[adRefenreceDateComponents setDay:1];
[adRefenreceDateComponents setMonth:1];
[adRefenreceDateComponents setYear:1601];
[adRefenreceDateComponents setEra:1];

NSDate *adRefenreceDate = [[NSCalendar calendarWithIdentifier:NSCalendarIdentifierISO8601] dateFromComponents:adRefenreceDateComponents];
NSTimeInterval expiryTimeInterval = [expiryTime integerValue] / 10000000.0;


self.passwordExpiryDate = [NSDate dateWithTimeInterval:expiryTimeInterval sinceDate:adRefenreceDate];
self.lastADRequestSucceded = YES;

[[NSUserDefaults standardUserDefaults] setInteger:[self.passwordExpiryDate timeIntervalSince1970] forKey:kHITPADPassExpiryTimeKey];
}
} else {
asl_log(NULL, NULL, ASL_LEVEL_INFO, "Unable to reach AD, working with old expiry date for AD Password.");
NSInteger expirySince1970 = [[NSUserDefaults standardUserDefaults] integerForKey:kHITPADPassExpiryTimeKey];
self.passwordExpiryDate = expirySince1970 > 0 ? [NSDate dateWithTimeIntervalSince1970:expirySince1970] : nil;
if (expirySince1970 == -1) {
self.passwordExpiryDate = nil;
} else {
self.passwordExpiryDate = expirySince1970 > 0 ? [NSDate dateWithTimeIntervalSince1970:expirySince1970] : nil;
}
self.lastADRequestSucceded = NO;

}
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/OpenApplication/OpenApplication/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>288</string>
<string>304</string>
<key>HITPFunctionIdentifier</key>
<string>public.open.application</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/OpenResource/OpenResource/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>288</string>
<string>304</string>
<key>HITPFunctionIdentifier</key>
<string>public.open.resource</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/Quit/Quit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>288</string>
<string>304</string>
<key>HITPFunctionIdentifier</key>
<string>public.quit</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/ScriptedItem/ScriptedItem/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>288</string>
<string>304</string>
<key>HITPFunctionIdentifier</key>
<string>public.script.item</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/Separator/Separator/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>288</string>
<string>304</string>
<key>HITPFunctionIdentifier</key>
<string>public.separator</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/SubMenu/SubMenu/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>288</string>
<string>304</string>
<key>HITPFunctionIdentifier</key>
<string>public.submenu</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/TestHTTP/TestHTTP/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>288</string>
<string>304</string>
<key>HITPFunctionIdentifier</key>
<string>public.test.http</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/Title/Title/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>288</string>
<string>304</string>
<key>HITPFunctionIdentifier</key>
<string>public.title</string>
<key>NSHumanReadableCopyright</key>
Expand Down

0 comments on commit e165227

Please sign in to comment.