diff options
author | ng0 <ng0@n0.is> | 2019-09-10 16:59:32 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-10 16:59:32 +0000 |
commit | 04b6df21cd281e8cd540139f8d9ae85defc1961c (patch) | |
tree | 6357199445df8d5c0c631bc8f10aef838b1f9f1e /src/util/service.c | |
parent | 483b0139a218a5f8a8311bda3eb23bcd88f57688 (diff) | |
download | gnunet-04b6df21cd281e8cd540139f8d9ae85defc1961c.tar.gz gnunet-04b6df21cd281e8cd540139f8d9ae85defc1961c.zip |
remove CYGWIN codeblocks, drop vendored Windows openvpn, drop win32 specific files.
configures and builds okay.
testsuite wasn't checked, will be checked.
diff including the plibc removal is now around 14370 lines of code less.
Diffstat (limited to 'src/util/service.c')
-rw-r--r-- | src/util/service.c | 110 |
1 files changed, 4 insertions, 106 deletions
diff --git a/src/util/service.c b/src/util/service.c index 880047a42..b0f4ea289 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -1354,93 +1354,6 @@ get_server_addresses(const char *service_name, | |||
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | 1356 | ||
1357 | #ifdef MINGW | ||
1358 | /** | ||
1359 | * Read listen sockets from the parent process (ARM). | ||
1360 | * | ||
1361 | * @param sh service context to initialize | ||
1362 | * @return NULL-terminated array of sockets on success, | ||
1363 | * NULL if not ok (must bind yourself) | ||
1364 | */ | ||
1365 | static struct GNUNET_NETWORK_Handle ** | ||
1366 | receive_sockets_from_parent(struct GNUNET_SERVICE_Handle *sh) | ||
1367 | { | ||
1368 | static struct GNUNET_NETWORK_Handle **lsocks; | ||
1369 | const char *env_buf; | ||
1370 | int fail; | ||
1371 | uint64_t count; | ||
1372 | uint64_t i; | ||
1373 | HANDLE lsocks_pipe; | ||
1374 | |||
1375 | env_buf = getenv("GNUNET_OS_READ_LSOCKS"); | ||
1376 | if ((NULL == env_buf) || (strlen(env_buf) <= 0)) | ||
1377 | return NULL; | ||
1378 | /* Using W32 API directly here, because this pipe will | ||
1379 | * never be used outside of this function, and it's just too much of a bother | ||
1380 | * to create a GNUnet API that boxes a HANDLE (the way it is done with socks) | ||
1381 | */ | ||
1382 | lsocks_pipe = (HANDLE)strtoul(env_buf, NULL, 10); | ||
1383 | if ((0 == lsocks_pipe) || (INVALID_HANDLE_VALUE == lsocks_pipe)) | ||
1384 | return NULL; | ||
1385 | fail = 1; | ||
1386 | do | ||
1387 | { | ||
1388 | int ret; | ||
1389 | int fail2; | ||
1390 | DWORD rd; | ||
1391 | |||
1392 | ret = ReadFile(lsocks_pipe, &count, sizeof(count), &rd, NULL); | ||
1393 | if ((0 == ret) || (sizeof(count) != rd) || (0 == count)) | ||
1394 | break; | ||
1395 | lsocks = GNUNET_new_array(count + 1, struct GNUNET_NETWORK_Handle *); | ||
1396 | |||
1397 | fail2 = 1; | ||
1398 | for (i = 0; i < count; i++) | ||
1399 | { | ||
1400 | WSAPROTOCOL_INFOA pi; | ||
1401 | uint64_t size; | ||
1402 | _win_socket s; | ||
1403 | |||
1404 | ret = ReadFile(lsocks_pipe, &size, sizeof(size), &rd, NULL); | ||
1405 | if ((0 == ret) || (sizeof(size) != rd) || (sizeof(pi) != size)) | ||
1406 | break; | ||
1407 | ret = ReadFile(lsocks_pipe, &pi, sizeof(pi), &rd, NULL); | ||
1408 | if ((0 == ret) || (sizeof(pi) != rd)) | ||
1409 | break; | ||
1410 | s = WSASocketA(pi.iAddressFamily, | ||
1411 | pi.iSocketType, | ||
1412 | pi.iProtocol, | ||
1413 | &pi, | ||
1414 | 0, | ||
1415 | WSA_FLAG_OVERLAPPED); | ||
1416 | lsocks[i] = GNUNET_NETWORK_socket_box_native(s); | ||
1417 | if (NULL == lsocks[i]) | ||
1418 | break; | ||
1419 | else if (i == count - 1) | ||
1420 | fail2 = 0; | ||
1421 | } | ||
1422 | if (fail2) | ||
1423 | break; | ||
1424 | lsocks[count] = NULL; | ||
1425 | fail = 0; | ||
1426 | } | ||
1427 | while (fail); | ||
1428 | CloseHandle(lsocks_pipe); | ||
1429 | |||
1430 | if (fail) | ||
1431 | { | ||
1432 | LOG(GNUNET_ERROR_TYPE_ERROR, | ||
1433 | _("Could not access a pre-bound socket, will try to bind myself\n")); | ||
1434 | for (i = 0; (i < count) && (NULL != lsocks[i]); i++) | ||
1435 | GNUNET_break(GNUNET_OK == GNUNET_NETWORK_socket_close(lsocks[i])); | ||
1436 | GNUNET_free(lsocks); | ||
1437 | return NULL; | ||
1438 | } | ||
1439 | return lsocks; | ||
1440 | } | ||
1441 | #endif | ||
1442 | |||
1443 | |||
1444 | /** | 1357 | /** |
1445 | * Create and initialize a listen socket for the server. | 1358 | * Create and initialize a listen socket for the server. |
1446 | * | 1359 | * |
@@ -1557,13 +1470,10 @@ setup_service(struct GNUNET_SERVICE_Handle *sh) | |||
1557 | { | 1470 | { |
1558 | int tolerant; | 1471 | int tolerant; |
1559 | struct GNUNET_NETWORK_Handle **lsocks; | 1472 | struct GNUNET_NETWORK_Handle **lsocks; |
1560 | |||
1561 | #ifndef MINGW | ||
1562 | const char *nfds; | 1473 | const char *nfds; |
1563 | unsigned int cnt; | 1474 | unsigned int cnt; |
1564 | int flags; | 1475 | int flags; |
1565 | char dummy[2]; | 1476 | char dummy[2]; |
1566 | #endif | ||
1567 | 1477 | ||
1568 | if (GNUNET_CONFIGURATION_have_value(sh->cfg, sh->service_name, "TOLERANT")) | 1478 | if (GNUNET_CONFIGURATION_have_value(sh->cfg, sh->service_name, "TOLERANT")) |
1569 | { | 1479 | { |
@@ -1583,7 +1493,7 @@ setup_service(struct GNUNET_SERVICE_Handle *sh) | |||
1583 | tolerant = GNUNET_NO; | 1493 | tolerant = GNUNET_NO; |
1584 | 1494 | ||
1585 | lsocks = NULL; | 1495 | lsocks = NULL; |
1586 | #ifndef MINGW | 1496 | |
1587 | errno = 0; | 1497 | errno = 0; |
1588 | if ((NULL != (nfds = getenv("LISTEN_FDS"))) && | 1498 | if ((NULL != (nfds = getenv("LISTEN_FDS"))) && |
1589 | (1 == sscanf(nfds, "%u%1s", &cnt, dummy)) && (cnt > 0) && | 1499 | (1 == sscanf(nfds, "%u%1s", &cnt, dummy)) && (cnt > 0) && |
@@ -1611,13 +1521,6 @@ setup_service(struct GNUNET_SERVICE_Handle *sh) | |||
1611 | } | 1521 | } |
1612 | unsetenv("LISTEN_FDS"); | 1522 | unsetenv("LISTEN_FDS"); |
1613 | } | 1523 | } |
1614 | #else | ||
1615 | if (NULL != getenv("GNUNET_OS_READ_LSOCKS")) | ||
1616 | { | ||
1617 | lsocks = receive_sockets_from_parent(sh); | ||
1618 | putenv("GNUNET_OS_READ_LSOCKS="); | ||
1619 | } | ||
1620 | #endif | ||
1621 | 1524 | ||
1622 | if (NULL != lsocks) | 1525 | if (NULL != lsocks) |
1623 | { | 1526 | { |
@@ -1723,7 +1626,7 @@ set_user_id(struct GNUNET_SERVICE_Handle *sh) | |||
1723 | 1626 | ||
1724 | if (NULL == (user = get_user_name(sh))) | 1627 | if (NULL == (user = get_user_name(sh))) |
1725 | return GNUNET_OK; /* keep */ | 1628 | return GNUNET_OK; /* keep */ |
1726 | #ifndef MINGW | 1629 | |
1727 | struct passwd *pws; | 1630 | struct passwd *pws; |
1728 | 1631 | ||
1729 | errno = 0; | 1632 | errno = 0; |
@@ -1754,7 +1657,7 @@ set_user_id(struct GNUNET_SERVICE_Handle *sh) | |||
1754 | return GNUNET_SYSERR; | 1657 | return GNUNET_SYSERR; |
1755 | } | 1658 | } |
1756 | } | 1659 | } |
1757 | #endif | 1660 | |
1758 | GNUNET_free(user); | 1661 | GNUNET_free(user); |
1759 | return GNUNET_OK; | 1662 | return GNUNET_OK; |
1760 | } | 1663 | } |
@@ -1808,7 +1711,6 @@ pid_file_delete(struct GNUNET_SERVICE_Handle *sh) | |||
1808 | static int | 1711 | static int |
1809 | detach_terminal(struct GNUNET_SERVICE_Handle *sh) | 1712 | detach_terminal(struct GNUNET_SERVICE_Handle *sh) |
1810 | { | 1713 | { |
1811 | #ifndef MINGW | ||
1812 | pid_t pid; | 1714 | pid_t pid; |
1813 | int nullfd; | 1715 | int nullfd; |
1814 | int filedes[2]; | 1716 | int filedes[2]; |
@@ -1875,11 +1777,7 @@ detach_terminal(struct GNUNET_SERVICE_Handle *sh) | |||
1875 | if (-1 == pid) | 1777 | if (-1 == pid) |
1876 | LOG_STRERROR(GNUNET_ERROR_TYPE_ERROR, "setsid"); | 1778 | LOG_STRERROR(GNUNET_ERROR_TYPE_ERROR, "setsid"); |
1877 | sh->ready_confirm_fd = filedes[1]; | 1779 | sh->ready_confirm_fd = filedes[1]; |
1878 | #else | 1780 | |
1879 | /* FIXME: we probably need to do something else | ||
1880 | * elsewhere in order to fork the process itself... */ | ||
1881 | FreeConsole(); | ||
1882 | #endif | ||
1883 | return GNUNET_OK; | 1781 | return GNUNET_OK; |
1884 | } | 1782 | } |
1885 | 1783 | ||