-rw-r--r-- | src/eyefiservice.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/eyefiservice.cc b/src/eyefiservice.cc index 2586ade..e89b2fc 100644 --- a/src/eyefiservice.cc +++ b/src/eyefiservice.cc | |||
@@ -46,97 +46,97 @@ int eyefiService::StartSession( | |||
46 | r.transfermode=transfermode; | 46 | r.transfermode=transfermode; |
47 | r.transfermodetimestamp=transfermodetimestamp; | 47 | r.transfermodetimestamp=transfermodetimestamp; |
48 | r.upsyncallowed=false; | 48 | r.upsyncallowed=false; |
49 | 49 | ||
50 | std::string cmd = eyekinfig.get_on_start_session(); | 50 | std::string cmd = eyekinfig.get_on_start_session(); |
51 | if(!cmd.empty()) { | 51 | if(!cmd.empty()) { |
52 | if(detached_child()) { | 52 | if(detached_child()) { |
53 | putenv( gnu::autosprintf("EYEFI_MACADDRESS=%s",macaddress.c_str()) ); | 53 | putenv( gnu::autosprintf("EYEFI_MACADDRESS=%s",macaddress.c_str()) ); |
54 | putenv( gnu::autosprintf("EYEFI_TRANSFERMODE=%d",transfermode) ); | 54 | putenv( gnu::autosprintf("EYEFI_TRANSFERMODE=%d",transfermode) ); |
55 | putenv( gnu::autosprintf("EYEFI_TRANSFERMODETIMESTAMP=%ld",transfermodetimestamp) ); | 55 | putenv( gnu::autosprintf("EYEFI_TRANSFERMODETIMESTAMP=%ld",transfermodetimestamp) ); |
56 | char *argv[] = { (char*)"/bin/sh", (char*)"-c", (char*)cmd.c_str(), 0 }; | 56 | char *argv[] = { (char*)"/bin/sh", (char*)"-c", (char*)cmd.c_str(), 0 }; |
57 | execv("/bin/sh",argv); | 57 | execv("/bin/sh",argv); |
58 | syslog(LOG_ERR,"Failed to execute '%s'",cmd.c_str()); | 58 | syslog(LOG_ERR,"Failed to execute '%s'",cmd.c_str()); |
59 | _exit(-1); | 59 | _exit(-1); |
60 | } | 60 | } |
61 | } | 61 | } |
62 | return SOAP_OK; | 62 | return SOAP_OK; |
63 | }catch(std::runtime_error& e) { | 63 | }catch(std::runtime_error& e) { |
64 | syslog(LOG_ERR,"error while processing StartSession: %s",e.what()); | 64 | syslog(LOG_ERR,"error while processing StartSession: %s",e.what()); |
65 | return soap_receiverfault(e.what(),0); | 65 | return soap_receiverfault(e.what(),0); |
66 | } | 66 | } |
67 | 67 | ||
68 | int eyefiService::GetPhotoStatus( | 68 | int eyefiService::GetPhotoStatus( |
69 | std::string credential, std::string macaddress, | 69 | std::string credential, std::string macaddress, |
70 | std::string filename, long filesize, std::string filesignature, | 70 | std::string filename, long filesize, std::string filesignature, |
71 | int flags, | 71 | int flags, |
72 | struct rns__GetPhotoStatusResponse &r ) { | 72 | struct rns__GetPhotoStatusResponse &r ) { |
73 | #ifndef NDEBUG | 73 | #ifndef NDEBUG |
74 | syslog(LOG_DEBUG, | 74 | syslog(LOG_DEBUG, |
75 | "GetPhotoStatus request from %s with credential=%s, filename=%s, filesize=%ld, filesignature=%s, flags=%d; session nonce=%s", | 75 | "GetPhotoStatus request from %s with credential=%s, filename=%s, filesize=%ld, filesignature=%s, flags=%d; session nonce=%s", |
76 | macaddress.c_str(), credential.c_str(), filename.c_str(), filesize, filesignature.c_str(), flags, | 76 | macaddress.c_str(), credential.c_str(), filename.c_str(), filesize, filesignature.c_str(), flags, |
77 | session_nonce.hex().c_str() ); | 77 | session_nonce.hex().c_str() ); |
78 | #endif | 78 | #endif |
79 | 79 | ||
80 | std::string computed_credential = binary_t(macaddress+eyekinfig_t(macaddress).get_upload_key()+session_nonce.hex()).md5().hex(); | 80 | std::string computed_credential = binary_t(macaddress+eyekinfig_t(macaddress).get_upload_key()+session_nonce.hex()).md5().hex(); |
81 | 81 | ||
82 | #ifndef NDEBUG | 82 | #ifndef NDEBUG |
83 | syslog(LOG_DEBUG, " computed credential=%s", computed_credential.c_str()); | 83 | syslog(LOG_DEBUG, " computed credential=%s", computed_credential.c_str()); |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | if (credential != computed_credential) throw std::runtime_error("card authentication failed"); | 86 | if (credential != computed_credential) throw std::runtime_error("card authentication failed"); |
87 | 87 | ||
88 | r.fileid = 1; r.offset = 0; | 88 | r.fileid = 1; r.offset = 0; |
89 | return SOAP_OK; | 89 | return SOAP_OK; |
90 | } | 90 | } |
91 | 91 | ||
92 | int eyefiService::MarkLastPhotoInRoll( | 92 | int eyefiService::MarkLastPhotoInRoll( |
93 | std::string macaddress, int mergedelta, | 93 | std::string macaddress, int mergedelta, |
94 | struct rns__MarkLastPhotoInRollResponse &r ) { | 94 | struct rns__MarkLastPhotoInRollResponse&/* r */ ) { |
95 | #ifndef NDEBUG | 95 | #ifndef NDEBUG |
96 | syslog(LOG_DEBUG, | 96 | syslog(LOG_DEBUG, |
97 | "MarkLastPhotoInRoll request from %s with mergedelta=%d", | 97 | "MarkLastPhotoInRoll request from %s with mergedelta=%d", |
98 | macaddress.c_str(), mergedelta ); | 98 | macaddress.c_str(), mergedelta ); |
99 | #endif | 99 | #endif |
100 | std::string cmd = eyekinfig_t(macaddress).get_on_mark_last_photo_in_roll(); | 100 | std::string cmd = eyekinfig_t(macaddress).get_on_mark_last_photo_in_roll(); |
101 | if(!cmd.empty()) { | 101 | if(!cmd.empty()) { |
102 | if(detached_child()) { | 102 | if(detached_child()) { |
103 | putenv( gnu::autosprintf("EYEFI_MACADDRESS=%s",macaddress.c_str()) ); | 103 | putenv( gnu::autosprintf("EYEFI_MACADDRESS=%s",macaddress.c_str()) ); |
104 | putenv( gnu::autosprintf("EYEFI_MERGEDELTA=%d",mergedelta) ); | 104 | putenv( gnu::autosprintf("EYEFI_MERGEDELTA=%d",mergedelta) ); |
105 | char *argv[] = { (char*)"/bin/sh", (char*)"-c", (char*)cmd.c_str(), 0 }; | 105 | char *argv[] = { (char*)"/bin/sh", (char*)"-c", (char*)cmd.c_str(), 0 }; |
106 | execv("/bin/sh",argv); | 106 | execv("/bin/sh",argv); |
107 | syslog(LOG_ERR,"Failed to execute '%s'",cmd.c_str()); | 107 | syslog(LOG_ERR,"Failed to execute '%s'",cmd.c_str()); |
108 | _exit(-1); | 108 | _exit(-1); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | keep_alive = 0; | 111 | keep_alive = 0; |
112 | return SOAP_OK; | 112 | return SOAP_OK; |
113 | } | 113 | } |
114 | 114 | ||
115 | int eyefiService::UploadPhoto( | 115 | int eyefiService::UploadPhoto( |
116 | int fileid, std::string macaddress, | 116 | int fileid, std::string macaddress, |
117 | std::string filename, long filesize, std::string filesignature, | 117 | std::string filename, long filesize, std::string filesignature, |
118 | std::string encryption, int flags, | 118 | std::string encryption, int flags, |
119 | struct rns__UploadPhotoResponse& r ) { | 119 | struct rns__UploadPhotoResponse& r ) { |
120 | #ifndef NDEBUG | 120 | #ifndef NDEBUG |
121 | syslog(LOG_DEBUG, | 121 | syslog(LOG_DEBUG, |
122 | "UploadPhoto request from %s with fileid=%d, filename=%s, filesize=%ld," | 122 | "UploadPhoto request from %s with fileid=%d, filename=%s, filesize=%ld," |
123 | " filesignature=%s, encryption=%s, flags=%04X", | 123 | " filesignature=%s, encryption=%s, flags=%04X", |
124 | macaddress.c_str(), fileid, filename.c_str(), filesize, | 124 | macaddress.c_str(), fileid, filename.c_str(), filesize, |
125 | filesignature.c_str(), encryption.c_str(), flags ); | 125 | filesignature.c_str(), encryption.c_str(), flags ); |
126 | #endif | 126 | #endif |
127 | eyekinfig_t eyekinfig(macaddress); | 127 | eyekinfig_t eyekinfig(macaddress); |
128 | 128 | ||
129 | umask(eyekinfig.get_umask()); | 129 | umask(eyekinfig.get_umask()); |
130 | 130 | ||
131 | std::string td = eyekinfig.get_targetdir(); | 131 | std::string td = eyekinfig.get_targetdir(); |
132 | tmpdir_t indir(td+"/.incoming.XXXXXX"); | 132 | tmpdir_t indir(td+"/.incoming.XXXXXX"); |
133 | 133 | ||
134 | std::string tf,lf; | 134 | std::string tf,lf; |
135 | binary_t digest, idigest; | 135 | binary_t digest, idigest; |
136 | 136 | ||
137 | for(soap_multipart::iterator i=mime.begin(),ie=mime.end();i!=ie;++i) { | 137 | for(soap_multipart::iterator i=mime.begin(),ie=mime.end();i!=ie;++i) { |
138 | #ifndef NDEBUG | 138 | #ifndef NDEBUG |
139 | syslog(LOG_DEBUG, | 139 | syslog(LOG_DEBUG, |
140 | " MIME attachment with id=%s, type=%s, size=%ld", | 140 | " MIME attachment with id=%s, type=%s, size=%ld", |
141 | (*i).id, (*i).type, (long)(*i).size ); | 141 | (*i).id, (*i).type, (long)(*i).size ); |
142 | #endif | 142 | #endif |