Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: ports/samba/nacl.patch

Issue 1463173002: Fake implementation of get_interfaces. This is needed because getifaddrs fails under NaCl and the S… (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ports/samba/build.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 diff --git a/.gitignore b/.gitignore 1 diff --git a/.gitignore b/.gitignore
2 new file mode 100644 2 new file mode 100644
3 --- /dev/null 3 --- /dev/null
4 +++ b/.gitignore 4 +++ b/.gitignore
5 @@ -0,0 +1,2 @@ 5 @@ -0,0 +1,2 @@
6 +*.pyc 6 +*.pyc
7 +/bin 7 +/bin
8 diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_pyt hon.py 8 diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_pyt hon.py
9 --- a/buildtools/wafsamba/samba_python.py 9 --- a/buildtools/wafsamba/samba_python.py
10 +++ b/buildtools/wafsamba/samba_python.py 10 +++ b/buildtools/wafsamba/samba_python.py
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 @@ -540,7 +540,8 @@ removeea setea 122 @@ -540,7 +540,8 @@ removeea setea
123 define='HAVE_UNIXSOCKET', headers='sys/socket.h sys/un.h') 123 define='HAVE_UNIXSOCKET', headers='sys/socket.h sys/un.h')
124 124
125 125
126 - conf.CHECK_CODE(''' 126 - conf.CHECK_CODE('''
127 + if False: 127 + if False:
128 + conf.CHECK_CODE(''' 128 + conf.CHECK_CODE('''
129 struct stat st; 129 struct stat st;
130 char tpl[20]="/tmp/test.XXXXXX"; 130 char tpl[20]="/tmp/test.XXXXXX";
131 char tpl2[20]="/tmp/test.XXXXXX"; 131 char tpl2[20]="/tmp/test.XXXXXX";
132 diff --git a/lib/socket/interfaces.c b/lib/socket/interfaces.c
133 --- a/lib/socket/interfaces.c
134 +++ b/lib/socket/interfaces.c
135 @@ -25,6 +25,11 @@
136 #include "interfaces.h"
137 #include "lib/util/tsort.h"
138
139 +#if FAKE_GET_INTERFACES
140 +# include <sys/socket.h>
141 +# include <netinet/in.h>
142 +#endif
143 +
144 /****************************************************************************
145 Create a struct sockaddr_storage with the netmask bits set to 1.
146 ****************************************************************************/
147 @@ -138,9 +143,53 @@ static int _get_interfaces(TALLOC_CTX *mem_ctx, struct ifac e_struct **pifaces)
148 int total = 0;
149 size_t copy_size;
150
151 +#if FAKE_GET_INTERFACES
152 + // Under NaCl the API's to get network interfaces do not work. This code
153 + // path provides a fake response because if nothing is returned libsmbcl ient
154 + // will abort startup.
155 + //
156 + // The actual values returned here are never used as far as I can tell
157 + // and name resolution/NBT is done in javascript prior to calling libsmb client
158 + // for the purposes of the Chrome Samba app.
159 + iflist = talloc_array(mem_ctx, struct iface_struct, 1);
160 + if (iflist == NULL) {
161 + errno = ENOMEM;
162 + return -1;
163 + }
164 +
165 + iflist->ifa_next = NULL;
166 + iflist->ifa_name = talloc_strdup(mem_ctx, "fake");
167 + // This is what my real interface returned. It might only be necessary t o
168 + // be IFF_BROADCAST and IFF_UP?
169 + iflist->ifa_flags = 0x00011043;
170 +
171 + // IP Address
172 + struct sockaddr_in* addr = talloc(mem_ctx, struct sockaddr_in);
173 + addr->sin_family = AF_INET;
174 + addr->sin_port = 0;
175 + inet_aton("192.168.2.3", &addr->sin_addr.s_addr);
176 + iflist->ifa_addr = addr;
177 +
178 + // Net mask
179 + addr = talloc(mem_ctx, struct sockaddr_in);
180 + addr->sin_family = AF_INET;
181 + addr->sin_port = 0;
182 + inet_aton("255.255.255.0", &addr->sin_addr.s_addr);
183 + iflist->ifa_netmask = addr;
184 +
185 + // Broadcast address.
186 + addr = talloc(mem_ctx, struct sockaddr_in);
187 + addr->sin_family = AF_INET;
188 + addr->sin_port = 0;
189 + inet_aton("192.168.2.255", &addr->sin_addr.s_addr);
190 + iflist->ifa_broadaddr = addr;
191 +
192 + iflist->ifa_data = NULL;
193 +#else
194 if (getifaddrs(&iflist) < 0) {
195 return -1;
196 }
197 +#endif
198
199 count = 0;
200 for (ifptr = iflist; ifptr != NULL; ifptr = ifptr->ifa_next) {
201 @@ -223,7 +272,11 @@ static int _get_interfaces(TALLOC_CTX *mem_ctx, struct ifac e_struct **pifaces)
202 total++;
203 }
204
205 +// Since the iflist was allocated by talloc in the FAKE_GET_INTERFACES case it
206 +// doesn't need to be deleted.
207 +#if !FAKE_GET_INTERFACES
208 freeifaddrs(iflist);
209 +#endif
210
211 *pifaces = ifaces;
212 return total;
132 diff --git a/source3/wscript b/source3/wscript 213 diff --git a/source3/wscript b/source3/wscript
133 --- a/source3/wscript 214 --- a/source3/wscript
134 +++ b/source3/wscript 215 +++ b/source3/wscript
135 @@ -130,7 +130,7 @@ long ret = splice(0,0,1,0,400,SPLICE_F_MOVE); 216 @@ -130,7 +130,7 @@ long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
136 #endif 217 #endif
137 main() { 218 main() {
138 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0); 219 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
139 -}''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True, 220 -}''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True,
140 +}''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, #execute=True, 221 +}''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, #execute=True,
141 headers='fcntl.h signal.h', 222 headers='fcntl.h signal.h',
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 conf.SAMBA_CHECK_PERL(mandatory=True) 406 conf.SAMBA_CHECK_PERL(mandatory=True)
326 conf.find_program('xsltproc', var='XSLTPROC') 407 conf.find_program('xsltproc', var='XSLTPROC')
327 408
328 - conf.SAMBA_CHECK_PYTHON(mandatory=True, version=(2,5,0)) 409 - conf.SAMBA_CHECK_PYTHON(mandatory=True, version=(2,5,0))
329 - conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True) 410 - conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
330 + conf.SAMBA_CHECK_PYTHON(mandatory=False, version=(2,5,0)) 411 + conf.SAMBA_CHECK_PYTHON(mandatory=False, version=(2,5,0))
331 + conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False) 412 + conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
332 413
333 if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']: 414 if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
334 # Mac OSX needs to have this and it's also needed that the python is co mpiled with this 415 # Mac OSX needs to have this and it's also needed that the python is co mpiled with this
OLDNEW
« no previous file with comments | « ports/samba/build.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698