Skip to content

Commit 748ffaa

Browse files
committed
api: allow nil command for push-only mode; comment and text fixes
1 parent 9f658f1 commit 748ffaa

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

api/api.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (pe *PushEnqueuer) Push(ctx context.Context, ids []string) (*APIResult, int
6969
// contained within the API result.
7070
// A 500 value indicates only errors (with no successes).
7171
// A 207 value indicates some sucesses and some failures.
72-
// A 200 value indicates no errors (with only accesses).
72+
// A 200 value indicates no errors (with only successes).
7373
// Any other value is undefined.
7474
func (pe *PushEnqueuer) EnqueueWithPush(ctx context.Context, command *mdm.Command, ids []string, noPush bool) (*APIResult, int, error) {
7575
// setup our result accumulator
@@ -130,9 +130,12 @@ func code(r *APIResult, idCount int) int {
130130
// RawCommandEnqueueWithPush enqueues rawCommand and can send APNs pushes to ids.
131131
// See [EnqueueWithPush] for calling semantics.
132132
func (pe *PushEnqueuer) RawCommandEnqueueWithPush(ctx context.Context, rawCommand []byte, ids []string, noPush bool) (*APIResult, int, error) {
133-
command, err := mdm.DecodeCommand(rawCommand)
134-
if err != nil {
135-
return nil, 500, fmt.Errorf("decoding command: %w", err)
133+
var command *mdm.Command
134+
if len(rawCommand) > 0 {
135+
var err error
136+
if command, err = mdm.DecodeCommand(rawCommand); err != nil {
137+
return nil, 500, fmt.Errorf("decoding command: %w", err)
138+
}
136139
}
137140
return pe.EnqueueWithPush(ctx, command, ids, noPush)
138141
}

cmd/nanomdm/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func main() {
6969
flDump = flag.Bool("dump", false, "dump MDM requests and responses to stdout")
7070
flDisableMDM = flag.Bool("disable-mdm", false, "disable MDM HTTP endpoint")
7171
flCheckin = flag.Bool("checkin", false, "enable separate HTTP endpoint for MDM check-ins")
72-
flMigration = flag.Bool("migration", false, "HTTP endpoint for enrollment migrations")
72+
flMigration = flag.Bool("migration", false, "enable HTTP endpoint for enrollment migrations")
7373
flRetro = flag.Bool("retro", false, "Allow retroactive certificate-authorization association")
7474
flDMURLPfx = flag.String("dm", "", "URL to send Declarative Management requests to")
7575
flAuthProxy = flag.String("auth-proxy-url", "", "Reverse proxy URL target for MDM-authenticated HTTP requests")

docs/operations-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Note that the URL should likely have a trailing slash. Otherwise path elements o
172172

173173
### -migration
174174

175-
* HTTP endpoint for enrollment migrations
175+
* enable HTTP endpoint for enrollment migrations
176176

177177
NanoMDM supports a lossy form of MDM enrollment "migration." Essentially if a source MDM server can assemble enough of both Authenticate and TokenUpdate messages for an enrollment you can "migrate" enrollments by sending those Plist requests to the migration endpoint. Importantly this transfers the needed Push topic, token, and push magic to continue to send APNs push notifications to enrollments.
178178

0 commit comments

Comments
 (0)