Browse code
it builds, booyah!
Showing 5 changed files
... | ... |
@@ -1,17 +1,6 @@ |
1 |
+sudo: required |
|
2 |
+dist: trusty |
|
1 | 3 |
install: |
2 | 4 |
- sudo apt-get install libpam0g-dev |
3 | 5 |
language: cpp |
4 |
-sudo: required |
|
5 |
-script: |
|
6 |
- - sudo unlink /usr/bin/gcc && sudo ln -s /usr/bin/gcc-6 /usr/bin/gcc |
|
7 |
- - sudo unlink /usr/bin/g++ && sudo ln -s /usr/bin/g++-6 /usr/bin/g++ |
|
8 |
- - gcc --version |
|
9 |
- - ./configure && make && make test |
|
10 |
-addons: |
|
11 |
- apt: |
|
12 |
- sources: |
|
13 |
- - ubuntu-toolchain-r-test |
|
14 |
- packages: |
|
15 |
- - gcc-6 |
|
16 |
- - g++-6 |
|
17 | 6 |
|
... | ... |
@@ -1,9 +1,9 @@ |
1 | 1 |
CXXFLAGS += -fPIC -fno-stack-protector -std=c++11 |
2 | 2 |
CFLAGS += -fPIC -fno-stack-protector |
3 |
-LDFLAGS += -lpam |
|
3 |
+LDFLAGS = -lpam |
|
4 | 4 |
|
5 |
-OBJS = dual_control.o request.o dual_control_integrate.o validator.o conversation.o user.o \ |
|
6 |
- sys_unistd.o sys_pwd.o token.o sys_fstream.o sys_syslog.o logger.o pam.o |
|
5 |
+INTEGRATION_OBJS = sys_syslog.o sys_fstream.o sys_unistd.o sys_pwd.o pam.o dual_control_integrate.o |
|
6 |
+OBJS = dual_control.o request.o validator.o conversation.o user.o token.o logger.o |
|
7 | 7 |
TESTS = dual_control_test validator_test conversation_test request_test user_test token_test \ |
8 | 8 |
logger_test |
9 | 9 |
TESTOBJS = $(patsubst %,%.o,$(TESTS)) |
... | ... |
@@ -42,7 +42,7 @@ distclean: clean |
42 | 42 |
-include .depend |
43 | 43 |
|
44 | 44 |
$(TESTS): %: %.o $(OBJS) |
45 |
- @$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^ |
|
45 |
+ @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ $^ |
|
46 | 46 |
@./$@ |
47 | 47 |
|
48 | 48 |
.PHONY: test |
... | ... |
@@ -52,7 +52,7 @@ test: $(TESTS) |
52 | 52 |
.PHONY: install |
53 | 53 |
install: $(OBJS) |
54 | 54 |
ifeq ($(UNAME_S), Linux) |
55 |
- ld $(LDFLAGS) -x --shared -lpam -o $(DESTDIR)@PAM_MODULE_DIRECTORY@/$(MODULELIB) $(OBJS) |
|
55 |
+ ld $(LDFLAGS) -x --shared -o $(DESTDIR)@PAM_MODULE_DIRECTORY@/$(MODULELIB) $(OBJS) $(INTEGRATION_OBJS) |
|
56 | 56 |
else |
57 | 57 |
@echo installation recipe not known for $(UNAME_S) |
58 | 58 |
endif |
... | ... |
@@ -128,7 +128,7 @@ int authenticate_validates_with_received_token() |
128 | 128 |
use_conversation (configuration, new fake_conversation (user, token)); |
129 | 129 |
dual_control dc (dual_control::create (configuration)); |
130 | 130 |
pam_handle_t *handle (0); |
131 |
- std::vector<const std::string> arguments; |
|
131 |
+ std::vector<std::string> arguments; |
|
132 | 132 |
|
133 | 133 |
// when |
134 | 134 |
int actual = dc.authenticate (req()); |
... | ... |
@@ -18,13 +18,16 @@ class fake_pwd : public pwd_ifc |
18 | 18 |
{ |
19 | 19 |
private: |
20 | 20 |
std::string expected_user_name_; |
21 |
+ std::string home_directory_; |
|
21 | 22 |
public: |
22 | 23 |
fake_pwd (const std::string expected_user_name) : expected_user_name_ |
23 |
- (expected_user_name) {} |
|
24 |
+ (expected_user_name), home_directory_ ("/somehome") {} |
|
24 | 25 |
int getpwnam_r (const char *user_name, passwd *out, char *buffer, |
25 | 26 |
size_t buffer_sz, passwd **result) |
26 | 27 |
{ |
27 | 28 |
if (expected_user_name_ == user_name) { |
29 |
+ out->pw_dir = const_cast<char *> (home_directory_.c_str()); |
|
30 |
+ out->pw_name = const_cast<char *> (expected_user_name_.c_str()); |
|
28 | 31 |
*result = out; |
29 | 32 |
} else { |
30 | 33 |
*result = 0; |
... | ... |
@@ -38,6 +41,7 @@ class match_buffer_pwd : public pwd_ifc |
38 | 41 |
{ |
39 | 42 |
private: |
40 | 43 |
long int expected_buffer_sz_; |
44 |
+ std::string charbuf_; |
|
41 | 45 |
public: |
42 | 46 |
match_buffer_pwd (long int buffer_sz) : expected_buffer_sz_ (buffer_sz) {} |
43 | 47 |
int getpwnam_r (const char *user_name, passwd *out, char *buffer, |
... | ... |
@@ -45,6 +49,8 @@ public: |
45 | 49 |
{ |
46 | 50 |
|
47 | 51 |
if (expected_buffer_sz_ == buffer_sz && buffer != 0) { |
52 |
+ out->pw_name = const_cast<char *> (charbuf_.c_str()); |
|
53 |
+ out->pw_dir = const_cast<char *> (charbuf_.c_str()); |
|
48 | 54 |
*result = out; |
49 | 55 |
} else { |
50 | 56 |
*result = 0; |