path stringlengths 14 112 | content stringlengths 0 6.32M | size int64 0 6.32M | max_lines int64 1 100k | repo_name stringclasses 2
values | autogenerated bool 1
class |
|---|---|---|---|---|---|
pledge/LICENSE | ISC License
Copyright 2020 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR... | 759 | 17 | jart/plegde | false |
pledge/.gitignore | # -*- conf -*-
/o
# TODO: Find some way to have Python write to o/
__pycache__
*.tmp
/.bochs.log
/HTAGS
/TAGS
/bx_enh_dbg.ini
/tool/emacs/*.elc
/perf.data
/perf.data.old
| 173 | 16 | jart/plegde | false |
pledge/Makefile | # Makefiles are prettier like this
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. \
Please use GNU Make 3.82 or later)
endif
.RECIPEPREFIX = >
# Use bash as the shell
SHELL := bash
# ...And use strict flags with it to make sure things fail if a step in there
# fa... | 3,966 | 108 | jart/plegde | false |
pledge/.clang-format | ---
BasedOnStyle: Google
StatementMacros:
- INITIALIZER
AlignConsecutiveMacros: true
AlignConsecutiveDeclarations: false
AlwaysBreakBeforeMultilineStrings: false
AllowShortFunctionsOnASingleLine: false
KeepEmptyLinesAtTheStartOfBlocks: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
IncludeBlocks: Merge
---... | 399 | 18 | jart/plegde | false |
pledge/README.md | # pledge for linux
OpenBSD is an operating system that's famous for its focus on security.
Unfortunately, OpenBSD leader Theo states that there are only 7000 users
of OpenBSD. So it's a very small but elite group, that wields a
disproportionate influence; since we hear all the time about the awesome
security features ... | 2,697 | 56 | jart/plegde | false |
pledge/libc/macros.internal.h | #ifndef PLEDGE_LIBC_MACROS_INTERNAL_H_
#define PLEDGE_LIBC_MACROS_INTERNAL_H_
#define ROUNDUP(X, K) (((X) + (K)-1) & -(K))
#define ARRAYLEN(A) \
((sizeof(A) / sizeof(*(A))) / ((unsigned)!(sizeof(A) % sizeof(*(A)))))
#endif
| 227 | 9 | jart/plegde | false |
pledge/libc/dce.h | #ifndef PLEDGE_LIBC_DCE_H_
#define PLEDGE_LIBC_DCE_H_
#ifndef __linux__
#error "This program is extremely likely to only work properly on Linux !"
#endif
#define IsLinux() 1
#define IsWindows() 0
#define IsOpenbsd() 0
#endif
| 228 | 13 | jart/plegde | false |
pledge/libc/x/xdie.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 1,910 | 25 | jart/plegde | false |
pledge/libc/x/xstrcat.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,827 | 68 | jart/plegde | false |
pledge/libc/x/xmalloc.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,006 | 29 | jart/plegde | false |
pledge/libc/x/xstrdup.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,118 | 32 | jart/plegde | false |
pledge/libc/x/xjoinpaths.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,580 | 49 | jart/plegde | false |
pledge/libc/x/xrealloc.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,362 | 42 | jart/plegde | false |
pledge/libc/x/x.h | #ifndef PLEDGE_LIBC_X_X_H_
#define PLEDGE_LIBC_X_X_H_
#include "libc/integral/c.h"
_Noreturn void xdie(void);
void *xmalloc(size_t);
void *xrealloc(void *, size_t);
char *xstrdup(const char *);
char *xstrcat(const char *, ...);
#define xstrcat(...) (xstrcat)(__VA_ARGS__, NULL)
char *xjoinpaths(const char *, const cha... | 334 | 15 | jart/plegde | false |
pledge/libc/fmt/conv.h | #ifndef PLEDGE_LIBC_SIZETOL_H_
#define PLEDGE_LIBC_SIZETOL_H_
#include "libc/integral/c.h"
long sizetol(const char *, long) paramsnonnull() libcesque;
#endif
| 161 | 9 | jart/plegde | false |
pledge/libc/fmt/sizetol.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 4,055 | 113 | jart/plegde | false |
pledge/libc/fmt/joinpaths.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 3,244 | 72 | jart/plegde | false |
pledge/libc/elf/getelfsegmentheaderaddress.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,181 | 28 | jart/plegde | false |
pledge/libc/elf/checkelfaddress.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,362 | 33 | jart/plegde | false |
pledge/libc/elf/elf.h | #ifndef PLEDGE_LIBC_ELF_ELF_H_
#define PLEDGE_LIBC_ELF_ELF_H_
#include <elf.h>
#include <stddef.h>
void CheckElfAddress(const Elf64_Ehdr *, size_t, intptr_t, size_t);
Elf64_Phdr *GetElfSegmentHeaderAddress(const Elf64_Ehdr *, size_t, unsigned);
#endif
| 255 | 11 | jart/plegde | false |
pledge/libc/calls/blockcancel.internal.h | #ifndef PLEDGE_LIBC_CALLS_BLOCKCANCEL_INTERNAL_H_
#define PLEDGE_LIBC_CALLS_BLOCKCANCEL_INTERNAL_H_
#define ALLOW_CANCELLATIONS \
pthread_allow_cancellations(_cancelState); \
} \
while (0)
void pthread_allow_cancellations(int);
#define BLOCK_CANCELLA... | 483 | 19 | jart/plegde | false |
pledge/libc/calls/getcpucount.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,779 | 60 | jart/plegde | false |
pledge/libc/calls/islinux.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,054 | 28 | jart/plegde | false |
pledge/libc/calls/parsepromises.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,854 | 67 | jart/plegde | false |
pledge/libc/calls/commandv.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 6,718 | 173 | jart/plegde | false |
pledge/libc/calls/unveil.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 16,207 | 446 | jart/plegde | false |
pledge/libc/calls/calls.h | #ifndef PLEDGE_LIBC_CALLS_H_
#define PLEDGE_LIBC_CALLS_H_
#include <stddef.h>
char *commandv(const char *, char *, size_t);
int ioprio_set(int, int, int);
int pledge(const char *, const char *);
int unveil(const char *, const char *);
#endif
| 245 | 12 | jart/plegde | false |
pledge/libc/calls/pledge.h | #ifndef PLEDGE_LIBC_CALLS_PLEDGE_H_
#define PLEDGE_LIBC_CALLS_PLEDGE_H_
#define PLEDGE_PENALTY_KILL_THREAD 0x0000
#define PLEDGE_PENALTY_KILL_PROCESS 0x0001
#define PLEDGE_PENALTY_RETURN_EPERM 0x0002
#define PLEDGE_PENALTY_MASK 0x000f
#define PLEDGE_STDERR_LOGGING 0x0010
extern int __pledge_mode;
#en... | 324 | 14 | jart/plegde | false |
pledge/libc/calls/pledge-linux.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 69,089 | 2,143 | jart/plegde | false |
pledge/libc/calls/landlock_add_rule.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 3,208 | 54 | jart/plegde | false |
pledge/libc/calls/pledge.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 13,517 | 262 | jart/plegde | false |
pledge/libc/calls/landlock.h | #ifndef PLEDGE_LIBC_CALLS_LANDLOCK_H_
#define PLEDGE_LIBC_CALLS_LANDLOCK_H_
#include <linux/landlock.h>
#include <stdint.h>
#include <stddef.h>
/**
* Allow renaming or linking file to a different directory.
*
* @see https://lore.kernel.org/r/20220329125117.1393824-8-mic@digikod.net
* @see https://docs.kernel.org/... | 978 | 36 | jart/plegde | false |
pledge/libc/calls/landlock_create_ruleset.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 3,057 | 54 | jart/plegde | false |
pledge/libc/calls/syscall_support-sysv.internal.h | #ifndef PLEDGE_LIBC_CALLS_SYSCALL_SUPPORT_SYSV_INTERNAL_H_
#define PLEDGE_LIBC_CALLS_SYSCALL_SUPPORT_SYSV_INTERNAL_H_
#include <stdbool.h>
bool is_linux_2_6_23(void);
#endif
| 177 | 9 | jart/plegde | false |
pledge/libc/calls/landlock_restrict_self.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,792 | 48 | jart/plegde | false |
pledge/libc/calls/pledge.internal.h | #ifndef PLEDGE_LIBC_CALLS_PLEDGE_INTERNAL_H_
#define PLEDGE_LIBC_CALLS_PLEDGE_INTERNAL_H_
#include "libc/calls/pledge.h"
#include "libc/intrin/promises.internal.h"
#include <stdint.h>
#include <stddef.h>
struct Pledges {
const char *name;
const uint16_t *syscalls;
const size_t len;
};
extern const struct Pledg... | 447 | 21 | jart/plegde | false |
pledge/libc/intrin/safemacros.internal.h | #ifndef PLEDGE_LIBC_INTRIN_SAFEMACROS_INTERNAL_H_
#define PLEDGE_LIBC_INTRIN_SAFEMACROS_INTERNAL_H_
#include "libc/integral/c.h"
#define max(x, y) \
({ \
autotype(x) MaxX = (x); \
autotype(y) MaxY = (y); \
MaxX > MaxY ? MaxX : MaxY; \
})
#endif
| 309 | 14 | jart/plegde | false |
pledge/libc/intrin/kprintf.h | #ifndef PLEDGE_LIBC_INTRIN_KPRINTF_H_
#define PLEDGE_LIBC_INTRIN_KPRINTF_H_
#include <stdio.h>
#define kprintf printf
#define ksnprintf snprintf
#endif
| 155 | 10 | jart/plegde | false |
pledge/libc/intrin/promises.internal.h | #ifndef PLEDGE_LIBC_INTRIN_PROMISES_INTERNAL_H_
#define PLEDGE_LIBC_INTRIN_PROMISES_INTERNAL_H_
#define PROMISE_STDIO 0
#define PROMISE_RPATH 1
#define PROMISE_WPATH 2
#define PROMISE_CPATH 3
#define PROMISE_DPATH 4
#define PROMISE_FLOCK 5
#define PROMISE_FATTR 6
#define PROMISE_INET 7... | 833 | 32 | jart/plegde | false |
pledge/libc/intrin/pthread_setcancelstate.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,270 | 38 | jart/plegde | false |
pledge/libc/intrin/promises.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :viâ
âââââââââââââââââââââââââââââââââââââââââââââââââââ... | 2,082 | 27 | jart/plegde | false |
pledge/libc/intrin/likely.h | #ifndef PLEDGE_LIBC_INTRIN_LIKELY_H_
#define PLEDGE_LIBC_INTRIN_LIKELY_H_
#ifndef __STRICT_ANSI__
#define LIKELY(x) __builtin_expect(!!(x), 1)
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
#else
#define LIKELY(x)
#define UNLIKELY(x)
#endif
#endif
| 252 | 13 | jart/plegde | false |
pledge/libc/intrin/bits.h | #ifndef PLEDGE_LIBC_INTRIN_BITS_H_
#define PLEDGE_LIBC_INTRIN_BITS_H_
#include <stdint.h>
#ifdef __STRICT_ANSI__
#define READ32LE(S) \
((uint32_t)(255 & (S)[3]) << 030 | (uint32_t)(255 & (S)[2]) << 020 | \
(uint32_t)(255 & (S)[1]) << 010 | (uint32_t)(255 & (S)[0... | 1,497 | 33 | jart/plegde | false |
pledge/libc/integral/c.h | #ifndef PLEDGE_LIBC_INTEGRAL_C_H_
#define PLEDGE_LIBC_INTEGRAL_C_H_
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#ifndef __STRICT_ANSI__
#define pureconst __attribute__((__const__))
#else
#define pureconst
#endif
#if !defined(__STRICT_ANSI__) && \
(__has_attribute(__nonnull__) || \
(__GNU... | 4,386 | 149 | jart/plegde | false |
pledge/libc/sysv/calls/ioprio_set.c | #include "libc/calls/calls.h"
#include <sys/syscall.h>
#include <unistd.h>
int ioprio_set(int which, int who, int ioprio) {
return syscall(__NR_ioprio_set, which, who, ioprio);
}
| 183 | 9 | jart/plegde | false |
End of preview. Expand in Data Studio
- Downloads last month
- 5