Using xattr to set the Mac OSX quarantine property -


there lot of information on stackoverflow , elsewhere how clear mac quarantine property. in case set it. in order test app signed user hot "untrusted developer" warning after downloading it.

my app particularly large (we distribute large file download site, not store) , not convenient have upload , download test this. have had battles code signing past week testing important me.

once file has quarantine property see how can alter have values:

0002 = downloaded never opened (this 1 causes warning) 0022 = app aborted user warning dialogue (you hit 'cancel' in dialogue) 0062 = app opened (at least) once (you hit 'open' in dialogue) 

but don't know how give property in first place.

the code isn't hard, need fsref's it, deprecated. said, still works on 10.9. have link coreservices.

int main(int argc, const char * argv[]) {   @autoreleasepool {     if (argc != 2) {       printf("quarantine <path>\n");       exit(1);     }      nsstring *path = @(argv[1]);     osstatus result;     fsref pathref;     result = fspathmakeref((uint8*)[path utf8string], &pathref, 0);     if (result != noerr) {       nslog(@"error making ref (%d): %s", result, getmacosstatuscommentstring(result));       exit(result);     }      nsdictionary *quarantineproperties = @{(__bridge id)klsquarantinetypekey: (__bridge id)klsquarantinetypeotherdownload};      result = lssetitemattribute(&pathref,                                 klsrolesall,                                 klsitemquarantineproperties,                                 (__bridge cftyperef)quarantineproperties);      if (result != noerr) {       nslog(@"error setting attribute (%d): %s", result, getmacosstatuscommentstring(result));     }     exit(result);   }   return 0; } 

another approach copy quarantine information 1 file another. can serialize xattr information this:

xattr -p com.apple.quarantine file > file.xattr 

you can apply attributes file this:

xattr -w com.apple.quarantine "`cat file.xattr`" file 

(that should work, haven't tested quarantining in particular. use similar technique save code signatures , reapply them.)


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -