Skip to content

Instantly share code, notes, and snippets.

@punkeel

punkeel/Makefile Secret

Last active May 2, 2020
Embed
What would you like to do?
#include <stdio.h>
#include <stdlib.h>
#include "quarantine.h"
int main() {
/* Set Quarantine */
qtn_proc_t qp = qtn_proc_alloc();
qtn_proc_set_identifier(qp, "com.punkeel.ohno");
qtn_proc_set_flags(qp, QTN_FLAG_SANDBOX | QTN_FLAG_HARD);
qtn_proc_apply_to_self(qp);
qtn_proc_free(qp);
FILE *fp;
fp = fopen("test.txt", "w+");
fprintf(fp, "This is testing for fprintf...\n");
fputs("This is testing for fputs...\n", fp);
fclose(fp);
return 0;
}
.PHONY: all clean
all: main
./main
@echo " "
ls -lah@ test.txt
@echo " "
xattr -l test.txt
clean:
-rm test.txt main
/*
* Sources:
* https://github.com/dinfuehr/WebKit/blob/c2b4d6ec55d0864d311171702dc24c7c931cba95/Source/WebKit/Platform/spi/mac/QuarantineSPI.h
* https://github.com/Anandsystem/Anand/blob/bc28ac92c4615b60a5e336a2c6df633c26ab5a09/src/quarantine/include/quarantine.h
*/
#define QTN_FLAG_SANDBOX 1
#define QTN_FLAG_HARD 2
#define qtn_proc_alloc _qtn_proc_alloc
#define qtn_proc_apply_to_self _qtn_proc_apply_to_self
#define qtn_proc_free _qtn_proc_free
#define qtn_proc_set_flags _qtn_proc_set_flags
#define qtn_proc_set_identifier _qtn_proc_set_identifier
typedef struct _qtn_proc *qtn_proc_t;
int qtn_proc_apply_to_self(qtn_proc_t);
int qtn_proc_set_flags(qtn_proc_t, uint32_t flags);
qtn_proc_t qtn_proc_alloc();
void qtn_proc_free(qtn_proc_t);
void qtn_proc_set_identifier(qtn_proc_t proc, const char* ident);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment