-
Notifications
You must be signed in to change notification settings - Fork 12
/
octopass.h
97 lines (84 loc) · 3.37 KB
/
octopass.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Management linux user and authentication with the organization/team on Github.
Copyright (C) 2017 Tomohisa Oda
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef OCTOPASS_H
#define OCTOPASS_H
#include <curl/curl.h>
#include <errno.h>
#include <grp.h>
#include <jansson.h>
#include <nss.h>
#include <pthread.h>
#include <pwd.h>
#include <shadow.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <regex.h>
#include <unistd.h>
#define OCTOPASS_VERSION "0.7.1"
#define OCTOPASS_VERSION_WITH_NAME "octopass/" OCTOPASS_VERSION
#ifndef OCTOPASS_CONFIG_FILE
#define OCTOPASS_CONFIG_FILE "/etc/octopass.conf"
#endif
#define OCTOPASS_CACHE_DIR "/var/cache/octopass"
#define OCTOPASS_LOCK() \
do { \
pthread_mutex_lock(&OCTOPASS_MUTEX); \
} while (0);
#define OCTOPASS_UNLOCK() \
do { \
pthread_mutex_unlock(&OCTOPASS_MUTEX); \
} while (0);
// 10MB
#define OCTOPASS_MAX_BUFFER_SIZE (10 * 1024 * 1024)
#define MAXBUF 1024
#define DELIM "= "
// This macro is available with more than 2.5
#ifndef json_array_foreach
#define json_array_foreach(array, index, value) \
for (index = 0; index < json_array_size(array) && (value = json_array_get(array, index)); index++)
#endif
struct response {
char *data;
size_t size;
long *httpstatus;
};
struct config {
char endpoint[MAXBUF];
char token[MAXBUF];
char organization[MAXBUF];
char team[MAXBUF];
char owner[MAXBUF];
char repository[2048];
char permission[MAXBUF];
char group_name[MAXBUF];
char home[MAXBUF];
char shell[MAXBUF];
long uid_starts;
long gid;
long cache;
bool syslog;
char **shared_users;
int shared_users_count;
};
extern int octopass_members(struct config *con, struct response *res);
extern void octopass_config_loading(struct config *con, char *filename);
extern json_t *octopass_github_team_member_by_name(char *name, json_t *root);
extern json_t *octopass_github_team_member_by_id(int gh_id, json_t *root);
int octopass_autentication_with_token(struct config *con, char *user, char *token);
extern char *express_github_user_keys(struct config *con, char *user);
#endif /* OCTOPASS_H */