aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-06-08 15:46:14 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-06-08 15:46:14 +0200
commitc162a63997a3592f4d8a031cd31ee31bd1f17353 (patch)
tree41743b4bbc532fc03b5db7c64c9db50ee0591c88 /tests
parent3dcfac9148de47b625e421092ab4d6f407bd623d (diff)
parenta5f1e6f66a82a3630919353a396e77845586121b (diff)
downloadlibpam-x2go-c162a63997a3592f4d8a031cd31ee31bd1f17353.tar.gz
libpam-x2go-c162a63997a3592f4d8a031cd31ee31bd1f17353.tar.bz2
libpam-x2go-c162a63997a3592f4d8a031cd31ee31bd1f17353.zip
Merge branch 'sunweaver-pr/travis-ci'HEADmaster
Attributes GH PR #3: https://github.com/ArcticaProject/libpam-x2go/pull/3
Diffstat (limited to 'tests')
-rw-r--r--tests/mock_guest.c26
-rw-r--r--tests/mock_pam.c42
2 files changed, 42 insertions, 26 deletions
diff --git a/tests/mock_guest.c b/tests/mock_guest.c
index 316e851..6bdfc6f 100644
--- a/tests/mock_guest.c
+++ b/tests/mock_guest.c
@@ -24,42 +24,48 @@ static struct passwd guest = { "guest",
"/tmp",
"/bin/true" };
struct passwd *
-getpwnam (const char *username)
+getpwnam (const char __attribute__((unused)) *username)
{ return &guest; }
int
-setgroups(size_t size, const gid_t *list)
+setgroups(size_t __attribute__((unused)) size,
+ const __attribute__((unused)) gid_t *list)
{
errno = EPERM;
return -1;
}
int
-setgid(gid_t gid)
+setgid(gid_t __attribute__((unused)) gid)
{ return 0; }
int
-setuid(uid_t uid)
+setuid(uid_t __attribute__((unused)) uid)
{ return 0; }
int
-setegid(gid_t gid)
+setegid(gid_t __attribute__((unused)) gid)
{ return 0; }
int
-seteuid(uid_t uid)
+seteuid(uid_t __attribute__((unused)) uid)
{ return 0; }
-int chmod(const char *path, mode_t mode)
+int chmod(const char __attribute__((unused)) *path,
+ mode_t __attribute__((unused)) mode)
{ return 0; }
-int chown(const char *path, uid_t owner, gid_t group)
+int chown(const char __attribute__((unused)) *path,
+ uid_t __attribute__((unused)) owner,
+ gid_t __attribute__((unused)) group)
{ return 0; }
-int execvp(const char *file, char *const argv[])
+int execvp(const char __attribute__((unused)) *file,
+ char __attribute__((unused)) *const argv[])
{
return 0;
}
+
/* wrap _exit, to make sure the gcov_exit function installed with atexit()
is really called to collect coverage statistics */
void _exit (int exitcode)
@@ -86,7 +92,7 @@ socket_sucker ()
serv_addr.sun_family = AF_UNIX;
- int printsize = snprintf(serv_addr.sun_path, sizeof(serv_addr.sun_path) - 1, "%s/%s", home, ".x2go-socket");
+ long unsigned int printsize = (long unsigned int)snprintf(serv_addr.sun_path, sizeof(serv_addr.sun_path) - 1, "%s/%s", home, ".x2go-socket");
if (printsize > sizeof(serv_addr.sun_path) - 1 || printsize < 0) {
return -1;
}
diff --git a/tests/mock_pam.c b/tests/mock_pam.c
index 9111092..21fdde3 100644
--- a/tests/mock_pam.c
+++ b/tests/mock_pam.c
@@ -21,29 +21,34 @@ struct pam_handle {
/* note: the other fields have been omitted */
};
-int fake_conv (int num_msg, const struct pam_message **msg,
- struct pam_response **resp, void *appdata_ptr)
+int fake_conv (int __attribute__((unused)) num_msg,
+ const struct pam_message **msg,
+ struct pam_response **resp,
+ void __attribute__((unused)) *appdata_ptr)
{
struct pam_response *response = NULL;
response = malloc (sizeof (struct pam_response));
- if (response == NULL)
+ if (response == NULL) {
return PAM_BUF_ERR;
+ }
response->resp_retcode = 0;
- if (strcmp((*msg)->msg, PAM_X2GO_PROMPT_GUESTLOGIN) == 0)
+ if (strcmp((*msg)->msg, PAM_X2GO_PROMPT_GUESTLOGIN) == 0) {
response->resp = strdup ("guest"); /* IMPORTANT: this needs to be in /etc/passwd */
- else if (strcmp((*msg)->msg, PAM_X2GO_PROMPT_USER) == 0)
+ } else if (strcmp((*msg)->msg, PAM_X2GO_PROMPT_USER) == 0) {
response->resp = strdup ("ruser");
- else if (strcmp((*msg)->msg, PAM_X2GO_PROMPT_HOST) == 0)
+ } else if (strcmp((*msg)->msg, PAM_X2GO_PROMPT_HOST) == 0) {
response->resp = strdup ("protocol://rhost/dummy");
- else if (strcmp((*msg)->msg, PAM_X2GO_PROMPT_PASSWORD) == 0)
+ } else if (strcmp((*msg)->msg, PAM_X2GO_PROMPT_PASSWORD) == 0) {
response->resp = strdup ("password");
- else if (strcmp((*msg)->msg, PAM_X2GO_PROMPT_COMMAND) == 0)
+ } else if (strcmp((*msg)->msg, PAM_X2GO_PROMPT_COMMAND) == 0) {
response->resp = strdup ("rcommand");
- else
+ } else {
+ free(response);
return PAM_SYMBOL_ERR; /* leaks... */
+ }
*resp = response;
@@ -66,23 +71,26 @@ pam_handle_t *pam_handle_new (void)
int PAM_NONNULL((1)) pam_get_item (const pam_handle_t *pamh, int type, const void **value)
{
- if (pamh == NULL)
+ if (pamh == NULL) {
return PAM_SYSTEM_ERR;
+ }
- if (type == PAM_CONV)
+ if (type == PAM_CONV) {
*value = pamh->conv;
- else if (pamh->item[type] != NULL)
+ } else if (pamh->item[type] != NULL) {
*value = pamh->item[type];
- else
+ } else {
*value = NULL; /* will result in a prompt conversation */
+ }
return PAM_SUCCESS;
}
int PAM_NONNULL((1)) pam_set_item (pam_handle_t *pamh, int type, const void *value)
{
- if (pamh == NULL)
+ if (pamh == NULL) {
return PAM_SYSTEM_ERR;
+ }
void **slot, *tmp;
size_t nsize, osize;
@@ -90,10 +98,12 @@ int PAM_NONNULL((1)) pam_set_item (pam_handle_t *pamh, int type, const void *val
slot = &pamh->item[type];
osize = nsize = 0;
- if (*slot != NULL)
+ if (*slot != NULL) {
osize = strlen((const char *)*slot) + 1;
- if (value != NULL)
+ }
+ if (value != NULL) {
nsize = strlen((const char *)value) + 1;
+ }
if (*slot != NULL) {
memset(*slot, 0xd0, osize);