Mercurial > hg > truffle
comparison src/os/bsd/vm/attachListener_bsd.cpp @ 14393:f4f6ae481e1a
Merge
author | kvn |
---|---|
date | Thu, 27 Jun 2013 13:04:51 -0700 |
parents | e95fc50106cf |
children | 2e8f19c2feef |
comparison
equal
deleted
inserted
replaced
14392:b5c8a61d7fa0 | 14393:f4f6ae481e1a |
---|---|
197 addr.sun_family = AF_UNIX; | 197 addr.sun_family = AF_UNIX; |
198 strcpy(addr.sun_path, initial_path); | 198 strcpy(addr.sun_path, initial_path); |
199 ::unlink(initial_path); | 199 ::unlink(initial_path); |
200 int res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)); | 200 int res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)); |
201 if (res == -1) { | 201 if (res == -1) { |
202 RESTARTABLE(::close(listener), res); | 202 ::close(listener); |
203 return -1; | 203 return -1; |
204 } | 204 } |
205 | 205 |
206 // put in listen mode, set permissions, and rename into place | 206 // put in listen mode, set permissions, and rename into place |
207 res = ::listen(listener, 5); | 207 res = ::listen(listener, 5); |
215 res = ::rename(initial_path, path); | 215 res = ::rename(initial_path, path); |
216 } | 216 } |
217 } | 217 } |
218 } | 218 } |
219 if (res == -1) { | 219 if (res == -1) { |
220 RESTARTABLE(::close(listener), res); | 220 ::close(listener); |
221 ::unlink(initial_path); | 221 ::unlink(initial_path); |
222 return -1; | 222 return -1; |
223 } | 223 } |
224 set_path(path); | 224 set_path(path); |
225 set_listener(listener); | 225 set_listener(listener); |
343 // get the credentials of the peer and check the effective uid/guid | 343 // get the credentials of the peer and check the effective uid/guid |
344 // - check with jeff on this. | 344 // - check with jeff on this. |
345 uid_t puid; | 345 uid_t puid; |
346 gid_t pgid; | 346 gid_t pgid; |
347 if (::getpeereid(s, &puid, &pgid) != 0) { | 347 if (::getpeereid(s, &puid, &pgid) != 0) { |
348 int res; | 348 ::close(s); |
349 RESTARTABLE(::close(s), res); | |
350 continue; | 349 continue; |
351 } | 350 } |
352 uid_t euid = geteuid(); | 351 uid_t euid = geteuid(); |
353 gid_t egid = getegid(); | 352 gid_t egid = getegid(); |
354 | 353 |
355 if (puid != euid || pgid != egid) { | 354 if (puid != euid || pgid != egid) { |
356 int res; | 355 ::close(s); |
357 RESTARTABLE(::close(s), res); | |
358 continue; | 356 continue; |
359 } | 357 } |
360 | 358 |
361 // peer credential look okay so we read the request | 359 // peer credential look okay so we read the request |
362 BsdAttachOperation* op = read_request(s); | 360 BsdAttachOperation* op = read_request(s); |
363 if (op == NULL) { | 361 if (op == NULL) { |
364 int res; | 362 ::close(s); |
365 RESTARTABLE(::close(s), res); | |
366 continue; | 363 continue; |
367 } else { | 364 } else { |
368 return op; | 365 return op; |
369 } | 366 } |
370 } | 367 } |
411 BsdAttachListener::write_fully(this->socket(), (char*) st->base(), st->size()); | 408 BsdAttachListener::write_fully(this->socket(), (char*) st->base(), st->size()); |
412 ::shutdown(this->socket(), 2); | 409 ::shutdown(this->socket(), 2); |
413 } | 410 } |
414 | 411 |
415 // done | 412 // done |
416 RESTARTABLE(::close(this->socket()), rc); | 413 ::close(this->socket()); |
417 | 414 |
418 // were we externally suspended while we were waiting? | 415 // were we externally suspended while we were waiting? |
419 thread->check_and_wait_while_suspended(); | 416 thread->check_and_wait_while_suspended(); |
420 | 417 |
421 delete this; | 418 delete this; |