diff options
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/netapi/examples/server/server_getinfo.c | 16 | ||||
-rw-r--r-- | source3/lib/netapi/netapi.h | 612 | ||||
-rw-r--r-- | source3/lib/netapi/serverinfo.c | 272 | ||||
-rw-r--r-- | source3/lib/netapi/tests/Makefile.in | 2 | ||||
-rw-r--r-- | source3/lib/netapi/tests/common.h | 2 | ||||
-rw-r--r-- | source3/lib/netapi/tests/netapitest.c | 5 | ||||
-rw-r--r-- | source3/lib/netapi/tests/netserver.c | 61 | ||||
-rw-r--r-- | source3/lib/util_sock.c | 18 | ||||
-rw-r--r-- | source3/lib/wb_reqtrans.c | 181 | ||||
-rw-r--r-- | source3/lib/wbclient.c | 138 |
10 files changed, 1162 insertions, 145 deletions
diff --git a/source3/lib/netapi/examples/server/server_getinfo.c b/source3/lib/netapi/examples/server/server_getinfo.c index afd2edd05d..b6a665e4e0 100644 --- a/source3/lib/netapi/examples/server/server_getinfo.c +++ b/source3/lib/netapi/examples/server/server_getinfo.c @@ -38,6 +38,10 @@ int main(int argc, const char **argv) struct SERVER_INFO_100 *i100; struct SERVER_INFO_101 *i101; struct SERVER_INFO_102 *i102; + struct SERVER_INFO_402 *i402; + struct SERVER_INFO_403 *i403; + struct SERVER_INFO_502 *i502; + struct SERVER_INFO_503 *i503; struct SERVER_INFO_1005 *i1005; poptContext pc; @@ -112,6 +116,18 @@ int main(int argc, const char **argv) printf("licenses: %d\n", i102->sv102_licenses); printf("userpath: %s\n", i102->sv102_userpath); break; + case 402: + i402 = (struct SERVER_INFO_402 *)buffer; + break; + case 403: + i403 = (struct SERVER_INFO_403 *)buffer; + break; + case 502: + i502 = (struct SERVER_INFO_502 *)buffer; + break; + case 503: + i503 = (struct SERVER_INFO_503 *)buffer; + break; case 1005: i1005 = (struct SERVER_INFO_1005 *)buffer; printf("comment: %s\n", i1005->sv1005_comment); diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index 9687461920..e8cd71eec6 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -134,11 +134,623 @@ struct SERVER_INFO_102 { const char * sv102_userpath; }; +struct SERVER_INFO_402 { + uint32_t sv402_ulist_mtime; + uint32_t sv402_glist_mtime; + uint32_t sv402_alist_mtime; + const char * sv402_alerts; + uint32_t sv402_security; + uint32_t sv402_numadmin; + uint32_t sv402_lanmask; + const char * sv402_guestacct; + uint32_t sv402_chdevs; + uint32_t sv402_chdevq; + uint32_t sv402_chdevjobs; + uint32_t sv402_connections; + uint32_t sv402_shares; + uint32_t sv402_openfiles; + uint32_t sv402_sessopens; + uint32_t sv402_sessvcs; + uint32_t sv402_sessreqs; + uint32_t sv402_opensearch; + uint32_t sv402_activelocks; + uint32_t sv402_numreqbuf; + uint32_t sv402_sizreqbuf; + uint32_t sv402_numbigbuf; + uint32_t sv402_numfiletasks; + uint32_t sv402_alertsched; + uint32_t sv402_erroralert; + uint32_t sv402_logonalert; + uint32_t sv402_accessalert; + uint32_t sv402_diskalert; + uint32_t sv402_netioalert; + uint32_t sv402_maxauditsz; + const char * sv402_srvheuristics; +}; + +struct SERVER_INFO_403 { + uint32_t sv403_ulist_mtime; + uint32_t sv403_glist_mtime; + uint32_t sv403_alist_mtime; + const char * sv403_alerts; + uint32_t sv403_security; + uint32_t sv403_numadmin; + uint32_t sv403_lanmask; + const char * sv403_guestacct; + uint32_t sv403_chdevs; + uint32_t sv403_chdevq; + uint32_t sv403_chdevjobs; + uint32_t sv403_connections; + uint32_t sv403_shares; + uint32_t sv403_openfiles; + uint32_t sv403_sessopens; + uint32_t sv403_sessvcs; + uint32_t sv403_sessreqs; + uint32_t sv403_opensearch; + uint32_t sv403_activelocks; + uint32_t sv403_numreqbuf; + uint32_t sv403_sizreqbuf; + uint32_t sv403_numbigbuf; + uint32_t sv403_numfiletasks; + uint32_t sv403_alertsched; + uint32_t sv403_erroralert; + uint32_t sv403_logonalert; + uint32_t sv403_accessalert; + uint32_t sv403_diskalert; + uint32_t sv403_netioalert; + uint32_t sv403_maxauditsz; + const char * sv403_srvheuristics; + uint32_t sv403_auditedevents; + uint32_t sv403_autoprofile; + const char * sv403_autopath; +}; + +struct SERVER_INFO_502 { + uint32_t sv502_sessopens; + uint32_t sv502_sessvcs; + uint32_t sv502_opensearch; + uint32_t sv502_sizreqbuf; + uint32_t sv502_initworkitems; + uint32_t sv502_maxworkitems; + uint32_t sv502_rawworkitems; + uint32_t sv502_irpstacksize; + uint32_t sv502_maxrawbuflen; + uint32_t sv502_sessusers; + uint32_t sv502_sessconns; + uint32_t sv502_maxpagedmemoryusage; + uint32_t sv502_maxnonpagedmemoryusage; + uint8_t sv502_enablesoftcompat; + uint8_t sv502_enableforcedlogoff; + uint8_t sv502_timesource; + uint8_t sv502_acceptdownlevelapis; + uint8_t sv502_lmannounce; +}; + +struct SERVER_INFO_503 { + uint32_t sv503_sessopens; + uint32_t sv503_sessvcs; + uint32_t sv503_opensearch; + uint32_t sv503_sizreqbuf; + uint32_t sv503_initworkitems; + uint32_t sv503_maxworkitems; + uint32_t sv503_rawworkitems; + uint32_t sv503_irpstacksize; + uint32_t sv503_maxrawbuflen; + uint32_t sv503_sessusers; + uint32_t sv503_sessconns; + uint32_t sv503_maxpagedmemoryusage; + uint32_t sv503_maxnonpagedmemoryusage; + uint8_t sv503_enablesoftcompat; + uint8_t sv503_enableforcedlogoff; + uint8_t sv503_timesource; + uint8_t sv503_acceptdownlevelapis; + uint8_t sv503_lmannounce; + const char * sv503_domain; + uint32_t sv503_maxcopyreadlen; + uint32_t sv503_maxcopywritelen; + uint32_t sv503_minkeepsearch; + uint32_t sv503_maxkeepsearch; + uint32_t sv503_minkeepcomplsearch; + uint32_t sv503_maxkeepcomplsearch; + uint32_t sv503_threadcountadd; + uint32_t sv503_numblockthreads; + uint32_t sv503_scavtimeout; + uint32_t sv503_minrcvqueue; + uint32_t sv503_minfreeworkitems; + uint32_t sv503_xactmemsize; + uint32_t sv503_threadpriority; + uint32_t sv503_maxmpxct; + uint32_t sv503_oplockbreakwait; + uint32_t sv503_oplockbreakresponsewait; + uint8_t sv503_enableoplocks; + uint8_t sv503_enableoplockforceclose; + uint8_t sv503_enablefcbopens; + uint8_t sv503_enableraw; + uint8_t sv503_enablesharednetdrives; + uint32_t sv503_minfreeconnections; + uint32_t sv503_maxfreeconnections; +}; + +struct SERVER_INFO_599 { + uint32_t sv599_sessopens; + uint32_t sv599_sessvcs; + uint32_t sv599_opensearch; + uint32_t sv599_sizreqbuf; + uint32_t sv599_initworkitems; + uint32_t sv599_maxworkitems; + uint32_t sv599_rawworkitems; + uint32_t sv599_irpstacksize; + uint32_t sv599_maxrawbuflen; + uint32_t sv599_sessusers; + uint32_t sv599_sessconns; + uint32_t sv599_maxpagedmemoryusage; + uint32_t sv599_maxnonpagedmemoryusage; + uint8_t sv599_enablesoftcompat; + uint8_t sv599_enableforcedlogoff; + uint8_t sv599_timesource; + uint8_t sv599_acceptdownlevelapis; + uint8_t sv599_lmannounce; + const char * sv599_domain; + uint32_t sv599_maxcopyreadlen; + uint32_t sv599_maxcopywritelen; + uint32_t sv599_minkeepsearch; + uint32_t sv599_maxkeepsearch; + uint32_t sv599_minkeepcomplsearch; + uint32_t sv599_maxkeepcomplsearch; + uint32_t sv599_threadcountadd; + uint32_t sv599_numblockthreads; + uint32_t sv599_scavtimeout; + uint32_t sv599_minrcvqueue; + uint32_t sv599_minfreeworkitems; + uint32_t sv599_xactmemsize; + uint32_t sv599_threadpriority; + uint32_t sv599_maxmpxct; + uint32_t sv599_oplockbreakwait; + uint32_t sv599_oplockbreakresponsewait; + uint8_t sv599_enableoplocks; + uint8_t sv599_enableoplockforceclose; + uint8_t sv599_enablefcbopens; + uint8_t sv599_enableraw; + uint8_t sv599_enablesharednetdrives; + uint32_t sv599_minfreeconnections; + uint32_t sv599_maxfreeconnections; + uint32_t sv599_initsesstable; + uint32_t sv599_initconntable; + uint32_t sv599_initfiletable; + uint32_t sv599_initsearchtable; + uint32_t sv599_alertschedule; + uint32_t sv599_errorthreshold; + uint32_t sv599_networkerrorthreshold; + uint32_t sv599_diskspacethreshold; + uint32_t sv599_reserved; + uint32_t sv599_maxlinkdelay; + uint32_t sv599_minlinkthroughput; + uint32_t sv599_linkinfovalidtime; + uint32_t sv599_scavqosinfoupdatetime; + uint32_t sv599_maxworkitemidletime; +}; + +struct SERVER_INFO_598 { + uint32_t sv598_maxrawworkitems; + uint32_t sv598_maxthreadsperqueue; + uint32_t sv598_producttype; + uint32_t sv598_serversize; + uint32_t sv598_connectionlessautodisc; + uint32_t sv598_sharingviolationretries; + uint32_t sv598_sharingviolationdelay; + uint32_t sv598_maxglobalopensearch; + uint32_t sv598_removeduplicatesearches; + uint32_t sv598_lockviolationoffset; + uint32_t sv598_lockviolationdelay; + uint32_t sv598_mdlreadswitchover; + uint32_t sv598_cachedopenlimit; + uint32_t sv598_otherqueueaffinity; + uint8_t sv598_restrictnullsessaccess; + uint8_t sv598_enablewfw311directipx; + uint32_t sv598_queuesamplesecs; + uint32_t sv598_balancecount; + uint32_t sv598_preferredaffinity; + uint32_t sv598_maxfreerfcbs; + uint32_t sv598_maxfreemfcbs; + uint32_t sv598_maxfreelfcbs; + uint32_t sv598_maxfreepagedpoolchunks; + uint32_t sv598_minpagedpoolchunksize; + uint32_t sv598_maxpagedpoolchunksize; + uint8_t sv598_sendsfrompreferredprocessor; + uint32_t sv598_cacheddirectorylimit; + uint32_t sv598_maxcopylength; + uint8_t sv598_enablecompression; + uint8_t sv598_autosharewks; + uint8_t sv598_autoshareserver; + uint8_t sv598_enablesecuritysignature; + uint8_t sv598_requiresecuritysignature; + uint32_t sv598_minclientbuffersize; + struct GUID sv598_serverguid; + uint32_t sv598_ConnectionNoSessionsTimeout; + uint32_t sv598_IdleThreadTimeOut; + uint8_t sv598_enableW9xsecuritysignature; + uint8_t sv598_enforcekerberosreauthentication; + uint8_t sv598_disabledos; + uint32_t sv598_lowdiskspaceminimum; + uint8_t sv598_disablestrictnamechecking; +}; struct SERVER_INFO_1005 { const char * sv1005_comment; }; +struct SERVER_INFO_1107 { + uint32_t sv1107_users; +}; + +struct SERVER_INFO_1010 { + int32_t sv1010_disc; +}; + +struct SERVER_INFO_1016 { + uint8_t sv1016_hidden; +}; + +struct SERVER_INFO_1017 { + uint32_t sv1017_announce; +}; + +struct SERVER_INFO_1018 { + uint32_t sv1018_anndelta; +}; + +struct SERVER_INFO_1501 { + uint32_t sv1501_sessopens; +}; + +struct SERVER_INFO_1502 { + uint32_t sv1502_sessvcs; +}; + +struct SERVER_INFO_1503 { + uint32_t sv1503_opensearch; +}; + +struct SERVER_INFO_1506 { + uint32_t sv1506_maxworkitems; +}; + +struct SERVER_INFO_1509 { + uint32_t sv1509_maxrawbuflen; +}; + +struct SERVER_INFO_1510 { + uint32_t sv1510_sessusers; +}; + +struct SERVER_INFO_1511 { + uint32_t sv1511_sessconns; +}; + +struct SERVER_INFO_1512 { + uint32_t sv1512_maxnonpagedmemoryusage; +}; + +struct SERVER_INFO_1513 { + uint32_t sv1513_maxpagedmemoryusage; +}; + +struct SERVER_INFO_1514 { + uint8_t sv1514_enablesoftcompat; +}; + +struct SERVER_INFO_1515 { + uint8_t sv1515_enableforcedlogoff; +}; + +struct SERVER_INFO_1516 { + uint8_t sv1516_timesource; +}; + +struct SERVER_INFO_1518 { + uint8_t sv1518_lmannounce; +}; + +struct SERVER_INFO_1520 { + uint32_t sv1520_maxcopyreadlen; +}; + +struct SERVER_INFO_1521 { + uint32_t sv1521_maxcopywritelen; +}; + +struct SERVER_INFO_1522 { + uint32_t sv1522_minkeepsearch; +}; + +struct SERVER_INFO_1523 { + uint32_t sv1523_maxkeepsearch; +}; + +struct SERVER_INFO_1524 { + uint32_t sv1524_minkeepcomplsearch; +}; + +struct SERVER_INFO_1525 { + uint32_t sv1525_maxkeepcomplsearch; +}; + +struct SERVER_INFO_1528 { + uint32_t sv1528_scavtimeout; +}; + +struct SERVER_INFO_1529 { + uint32_t sv1529_minrcvqueue; +}; + +struct SERVER_INFO_1530 { + uint32_t sv1530_minfreeworkitems; +}; + +struct SERVER_INFO_1533 { + uint32_t sv1533_maxmpxct; +}; + +struct SERVER_INFO_1534 { + uint32_t sv1534_oplockbreakwait; +}; + +struct SERVER_INFO_1535 { + uint32_t sv1535_oplockbreakresponsewait; +}; + +struct SERVER_INFO_1536 { + uint8_t sv1536_enableoplocks; +}; + +struct SERVER_INFO_1537 { + uint8_t sv1537_enableoplockforceclose; +}; + +struct SERVER_INFO_1538 { + uint8_t sv1538_enablefcbopens; +}; + +struct SERVER_INFO_1539 { + uint8_t sv1539_enableraw; +}; + +struct SERVER_INFO_1540 { + uint8_t sv1540_enablesharednetdrives; +}; + +struct SERVER_INFO_1541 { + uint8_t sv1541_minfreeconnections; +}; + +struct SERVER_INFO_1542 { + uint8_t sv1542_maxfreeconnections; +}; + +struct SERVER_INFO_1543 { + uint32_t sv1543_initsesstable; +}; + +struct SERVER_INFO_1544 { + uint32_t sv1544_initconntable; +}; + +struct SERVER_INFO_1545 { + uint32_t sv1545_initfiletable; +}; + +struct SERVER_INFO_1546 { + uint32_t sv1546_initsearchtable; +}; + +struct SERVER_INFO_1547 { + uint32_t sv1547_alertschedule; +}; + +struct SERVER_INFO_1548 { + uint32_t sv1548_errorthreshold; +}; + +struct SERVER_INFO_1549 { + uint32_t sv1549_networkerrorthreshold; +}; + +struct SERVER_INFO_1550 { + uint32_t sv1550_diskspacethreshold; +}; + +struct SERVER_INFO_1552 { + uint32_t sv1552_maxlinkdelay; +}; + +struct SERVER_INFO_1553 { + uint32_t sv1553_minlinkthroughput; +}; + +struct SERVER_INFO_1554 { + uint32_t sv1554_linkinfovalidtime; +}; + +struct SERVER_INFO_1555 { + uint32_t sv1555_scavqosinfoupdatetime; +}; + +struct SERVER_INFO_1556 { + uint32_t sv1556_maxworkitemidletime; +}; + +struct SERVER_INFO_1557 { + uint32_t sv1557_maxrawworkitems; +}; + +struct SERVER_INFO_1560 { + uint32_t sv1560_producttype; +}; + +struct SERVER_INFO_1561 { + uint32_t sv1561_serversize; +}; + +struct SERVER_INFO_1562 { + uint32_t sv1562_connectionlessautodisc; +}; + +struct SERVER_INFO_1563 { + uint32_t sv1563_sharingviolationretries; +}; + +struct SERVER_INFO_1564 { + uint32_t sv1564_sharingviolationdelay; +}; + +struct SERVER_INFO_1565 { + uint32_t sv1565_maxglobalopensearch; +}; + +struct SERVER_INFO_1566 { + uint8_t sv1566_removeduplicatesearches; +}; + +struct SERVER_INFO_1567 { + uint32_t sv1567_lockviolationretries; +}; + +struct SERVER_INFO_1568 { + uint32_t sv1568_lockviolationoffset; +}; + +struct SERVER_INFO_1569 { + uint32_t sv1569_lockviolationdelay; +}; + +struct SERVER_INFO_1570 { + uint32_t sv1570_mdlreadswitchover; +}; + +struct SERVER_INFO_1571 { + uint32_t sv1571_cachedopenlimit; +}; + +struct SERVER_INFO_1572 { + uint32_t sv1572_criticalthreads; +}; + +struct SERVER_INFO_1573 { + uint32_t sv1573_restrictnullsessaccess; +}; + +struct SERVER_INFO_1574 { + uint32_t sv1574_enablewfw311directipx; +}; + +struct SERVER_INFO_1575 { + uint32_t sv1575_otherqueueaffinity; +}; + +struct SERVER_INFO_1576 { + uint32_t sv1576_queuesamplesecs; +}; + +struct SERVER_INFO_1577 { + uint32_t sv1577_balancecount; +}; + +struct SERVER_INFO_1578 { + uint32_t sv1578_preferredaffinity; +}; + +struct SERVER_INFO_1579 { + uint32_t sv1579_maxfreerfcbs; +}; + +struct SERVER_INFO_1580 { + uint32_t sv1580_maxfreemfcbs; +}; + +struct SERVER_INFO_1581 { + uint32_t sv1581_maxfreemlcbs; +}; + +struct SERVER_INFO_1582 { + uint32_t sv1582_maxfreepagedpoolchunks; +}; + +struct SERVER_INFO_1583 { + uint32_t sv1583_minpagedpoolchunksize; +}; + +struct SERVER_INFO_1584 { + uint32_t sv1584_maxpagedpoolchunksize; +}; + +struct SERVER_INFO_1585 { + uint8_t sv1585_sendsfrompreferredprocessor; +}; + +struct SERVER_INFO_1586 { + uint32_t sv1586_maxthreadsperqueue; +}; + +struct SERVER_INFO_1587 { + uint32_t sv1587_cacheddirectorylimit; +}; + +struct SERVER_INFO_1588 { + uint32_t sv1588_maxcopylength; +}; + +struct SERVER_INFO_1590 { + uint32_t sv1590_enablecompression; +}; + +struct SERVER_INFO_1591 { + uint32_t sv1591_autosharewks; +}; + +struct SERVER_INFO_1592 { + uint32_t sv1592_autosharewks; +}; + +struct SERVER_INFO_1593 { + uint32_t sv1593_enablesecuritysignature; +}; + +struct SERVER_INFO_1594 { + uint32_t sv1594_requiresecuritysignature; +}; + +struct SERVER_INFO_1595 { + uint32_t sv1595_minclientbuffersize; +}; + +struct SERVER_INFO_1596 { + uint32_t sv1596_ConnectionNoSessionsTimeout; +}; + +struct SERVER_INFO_1597 { + uint32_t sv1597_IdleThreadTimeOut; +}; + +struct SERVER_INFO_1598 { + uint32_t sv1598_enableW9xsecuritysignature; +}; + +struct SERVER_INFO_1599 { + uint8_t sv1598_enforcekerberosreauthentication; +}; + +struct SERVER_INFO_1600 { + uint8_t sv1598_disabledos; +}; + +struct SERVER_INFO_1601 { + uint32_t sv1598_lowdiskspaceminimum; +}; + +struct SERVER_INFO_1602 { + uint8_t sv_1598_disablestrictnamechecking; +}; + struct USER_INFO_0 { const char * usri0_name; }; diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c index d77145eef3..02396a7bba 100644 --- a/source3/lib/netapi/serverinfo.c +++ b/source3/lib/netapi/serverinfo.c @@ -94,8 +94,108 @@ static NTSTATUS map_server_info_to_SERVER_INFO_buffer(TALLOC_CTX *mem_ctx, struct SERVER_INFO_100 i100; struct SERVER_INFO_101 i101; struct SERVER_INFO_102 i102; + struct SERVER_INFO_402 i402; + struct SERVER_INFO_403 i403; + struct SERVER_INFO_502 i502; + struct SERVER_INFO_503 i503; + struct SERVER_INFO_598 i598; + struct SERVER_INFO_599 i599; struct SERVER_INFO_1005 i1005; - +#if 0 + struct SERVER_INFO_1010 i1010; + struct SERVER_INFO_1016 i1016; + struct SERVER_INFO_1017 i1017; + struct SERVER_INFO_1018 i1018; + struct SERVER_INFO_1107 i1107; + struct SERVER_INFO_1501 i1501; + struct SERVER_INFO_1502 i1502; + struct SERVER_INFO_1503 i1503; + struct SERVER_INFO_1506 i1506; + struct SERVER_INFO_1509 i1509; + struct SERVER_INFO_1510 i1510; + struct SERVER_INFO_1511 i1511; + struct SERVER_INFO_1512 i1512; + struct SERVER_INFO_1513 i1513; + struct SERVER_INFO_1514 i1514; + struct SERVER_INFO_1515 i1515; + struct SERVER_INFO_1516 i1516; + struct SERVER_INFO_1518 i1518; + struct SERVER_INFO_1520 i1520; + struct SERVER_INFO_1521 i1521; + struct SERVER_INFO_1522 i1522; + struct SERVER_INFO_1523 i1523; + struct SERVER_INFO_1524 i1524; + struct SERVER_INFO_1525 i1525; + struct SERVER_INFO_1528 i1528; + struct SERVER_INFO_1529 i1529; + struct SERVER_INFO_1530 i1530; + struct SERVER_INFO_1533 i1533; + struct SERVER_INFO_1534 i1534; + struct SERVER_INFO_1535 i1535; + struct SERVER_INFO_1536 i1536; + struct SERVER_INFO_1537 i1537; + struct SERVER_INFO_1538 i1538; + struct SERVER_INFO_1539 i1539; + struct SERVER_INFO_1540 i1540; + struct SERVER_INFO_1541 i1541; + struct SERVER_INFO_1542 i1542; + struct SERVER_INFO_1543 i1543; + struct SERVER_INFO_1544 i1544; + struct SERVER_INFO_1545 i1545; + struct SERVER_INFO_1546 i1546; + struct SERVER_INFO_1547 i1547; + struct SERVER_INFO_1548 i1548; + struct SERVER_INFO_1549 i1549; + struct SERVER_INFO_1550 i1550; + struct SERVER_INFO_1552 i1552; + struct SERVER_INFO_1553 i1553; + struct SERVER_INFO_1554 i1554; + struct SERVER_INFO_1555 i1555; + struct SERVER_INFO_1556 i1556; + struct SERVER_INFO_1557 i1557; + struct SERVER_INFO_1560 i1560; + struct SERVER_INFO_1561 i1561; + struct SERVER_INFO_1562 i1562; + struct SERVER_INFO_1563 i1563; + struct SERVER_INFO_1564 i1564; + struct SERVER_INFO_1565 i1565; + struct SERVER_INFO_1566 i1566; + struct SERVER_INFO_1567 i1567; + struct SERVER_INFO_1568 i1568; + struct SERVER_INFO_1569 i1569; + struct SERVER_INFO_1570 i1570; + struct SERVER_INFO_1571 i1571; + struct SERVER_INFO_1572 i1572; + struct SERVER_INFO_1573 i1573; + struct SERVER_INFO_1574 i1574; + struct SERVER_INFO_1575 i1575; + struct SERVER_INFO_1576 i1576; + struct SERVER_INFO_1577 i1577; + struct SERVER_INFO_1578 i1578; + struct SERVER_INFO_1579 i1579; + struct SERVER_INFO_1580 i1580; + struct SERVER_INFO_1581 i1581; + struct SERVER_INFO_1582 i1582; + struct SERVER_INFO_1583 i1583; + struct SERVER_INFO_1584 i1584; + struct SERVER_INFO_1585 i1585; + struct SERVER_INFO_1586 i1586; + struct SERVER_INFO_1587 i1587; + struct SERVER_INFO_1588 i1588; + struct SERVER_INFO_1590 i1590; + struct SERVER_INFO_1591 i1591; + struct SERVER_INFO_1592 i1592; + struct SERVER_INFO_1593 i1593; + struct SERVER_INFO_1594 i1594; + struct SERVER_INFO_1595 i1595; + struct SERVER_INFO_1596 i1596; + struct SERVER_INFO_1597 i1597; + struct SERVER_INFO_1598 i1598; + struct SERVER_INFO_1599 i1599; + struct SERVER_INFO_1600 i1600; + struct SERVER_INFO_1601 i1601; + struct SERVER_INFO_1602 i1602; +#endif uint32_t num_info = 0; switch (level) { @@ -141,6 +241,173 @@ static NTSTATUS map_server_info_to_SERVER_INFO_buffer(TALLOC_CTX *mem_ctx, &num_info); break; + case 402: + + i402.sv402_ulist_mtime = i->info402->ulist_mtime; + i402.sv402_glist_mtime = i->info402->glist_mtime; + i402.sv402_alist_mtime = i->info402->alist_mtime; + i402.sv402_alerts = talloc_strdup(mem_ctx, i->info402->alerts); + i402.sv402_security = i->info402->security; + i402.sv402_numadmin = i->info402->numadmin; + i402.sv402_lanmask = i->info402->lanmask; + i402.sv402_guestacct = talloc_strdup(mem_ctx, i->info402->guestaccount); + i402.sv402_chdevs = i->info402->chdevs; + i402.sv402_chdevq = i->info402->chdevqs; + i402.sv402_chdevjobs = i->info402->chdevjobs; + i402.sv402_connections = i->info402->connections; + i402.sv402_shares = i->info402->shares; + i402.sv402_openfiles = i->info402->openfiles; + i402.sv402_sessopens = i->info402->sessopen; + i402.sv402_sessvcs = i->info402->sesssvc; + i402.sv402_sessreqs = i->info402->sessreqs; + i402.sv402_opensearch = i->info402->opensearch; + i402.sv402_activelocks = i->info402->activelocks; + i402.sv402_numreqbuf = i->info402->numreqbufs; + i402.sv402_sizreqbuf = i->info402->sizereqbufs; + i402.sv402_numbigbuf = i->info402->numbigbufs; + i402.sv402_numfiletasks = i->info402->numfiletasks; + i402.sv402_alertsched = i->info402->alertsched; + i402.sv402_erroralert = i->info402->erroralert; + i402.sv402_logonalert = i->info402->logonalert; + i402.sv402_accessalert = i->info402->accessalert; + i402.sv402_diskalert = i->info402->diskalert; + i402.sv402_netioalert = i->info402->netioalert; + i402.sv402_maxauditsz = i->info402->maxaudits; + i402.sv402_srvheuristics = i->info402->srvheuristics; + + ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_402, i402, + (struct SERVER_INFO_402 **)buffer, + &num_info); + break; + + case 403: + + i403.sv403_ulist_mtime = i->info403->ulist_mtime; + i403.sv403_glist_mtime = i->info403->glist_mtime; + i403.sv403_alist_mtime = i->info403->alist_mtime; + i403.sv403_alerts = talloc_strdup(mem_ctx, i->info403->alerts); + i403.sv403_security = i->info403->security; + i403.sv403_numadmin = i->info403->numadmin; + i403.sv403_lanmask = i->info403->lanmask; + i403.sv403_guestacct = talloc_strdup(mem_ctx, i->info403->guestaccount); + i403.sv403_chdevs = i->info403->chdevs; + i403.sv403_chdevq = i->info403->chdevqs; + i403.sv403_chdevjobs = i->info403->chdevjobs; + i403.sv403_connections = i->info403->connections; + i403.sv403_shares = i->info403->shares; + i403.sv403_openfiles = i->info403->openfiles; + i403.sv403_sessopens = i->info403->sessopen; + i403.sv403_sessvcs = i->info403->sesssvc; + i403.sv403_sessreqs = i->info403->sessreqs; + i403.sv403_opensearch = i->info403->opensearch; + i403.sv403_activelocks = i->info403->activelocks; + i403.sv403_numreqbuf = i->info403->numreqbufs; + i403.sv403_sizreqbuf = i->info403->sizereqbufs; + i403.sv403_numbigbuf = i->info403->numbigbufs; + i403.sv403_numfiletasks = i->info403->numfiletasks; + i403.sv403_alertsched = i->info403->alertsched; + i403.sv403_erroralert = i->info403->erroralert; + i403.sv403_logonalert = i->info403->logonalert; + i403.sv403_accessalert = i->info403->accessalert; + i403.sv403_diskalert = i->info403->diskalert; + i403.sv403_netioalert = i->info403->netioalert; + i403.sv403_maxauditsz = i->info403->maxaudits; + i403.sv403_srvheuristics = i->info403->srvheuristics; + i403.sv403_auditedevents = i->info403->auditedevents; + i403.sv403_autoprofile = i->info403->auditprofile; + i403.sv403_autopath = talloc_strdup(mem_ctx, i->info403->autopath); + + ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_403, i403, + (struct SERVER_INFO_403 **)buffer, + &num_info); + break; + + case 502: + i502.sv502_sessopens = i->info502->sessopen; + i502.sv502_sessvcs = i->info502->sesssvc; + i502.sv502_opensearch = i->info502->opensearch; + i502.sv502_sizreqbuf = i->info502->sizereqbufs; + i502.sv502_initworkitems = i->info502->initworkitems; + i502.sv502_maxworkitems = i->info502->maxworkitems; + i502.sv502_rawworkitems = i->info502->rawworkitems; + i502.sv502_irpstacksize = i->info502->irpstacksize; + i502.sv502_maxrawbuflen = i->info502->maxrawbuflen; + i502.sv502_sessusers = i->info502->sessusers; + i502.sv502_sessconns = i->info502->sessconns; + i502.sv502_maxpagedmemoryusage = i->info502->maxpagedmemoryusage; + i502.sv502_maxnonpagedmemoryusage = i->info502->maxnonpagedmemoryusage; + i502.sv502_enablesoftcompat = i->info502->enablesoftcompat; + i502.sv502_enableforcedlogoff = i->info502->enableforcedlogoff; + i502.sv502_timesource = i->info502->timesource; + i502.sv502_acceptdownlevelapis = i->info502->acceptdownlevelapis; + i502.sv502_lmannounce = i->info502->lmannounce; + + ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_502, i502, + (struct SERVER_INFO_502 **)buffer, + &num_info); + break; + + case 503: + i503.sv503_sessopens = i->info503->sessopen; + i503.sv503_sessvcs = i->info503->sesssvc; + i503.sv503_opensearch = i->info503->opensearch; + i503.sv503_sizreqbuf = i->info503->sizereqbufs; + i503.sv503_initworkitems = i->info503->initworkitems; + i503.sv503_maxworkitems = i->info503->maxworkitems; + i503.sv503_rawworkitems = i->info503->rawworkitems; + i503.sv503_irpstacksize = i->info503->irpstacksize; + i503.sv503_maxrawbuflen = i->info503->maxrawbuflen; + i503.sv503_sessusers = i->info503->sessusers; + i503.sv503_sessconns = i->info503->sessconns; + i503.sv503_maxpagedmemoryusage = i->info503->maxpagedmemoryusage; + i503.sv503_maxnonpagedmemoryusage = i->info503->maxnonpagedmemoryusage; + i503.sv503_enablesoftcompat = i->info503->enablesoftcompat; + i503.sv503_enableforcedlogoff = i->info503->enableforcedlogoff; + i503.sv503_timesource = i->info503->timesource; + i503.sv503_acceptdownlevelapis = i->info503->acceptdownlevelapis; + i503.sv503_lmannounce = i->info503->lmannounce; + i503.sv503_domain = talloc_strdup(mem_ctx, i->info503->domain); + i503.sv503_maxcopyreadlen = i->info503->maxcopyreadlen; + i503.sv503_maxcopywritelen = i->info503->maxcopywritelen; + i503.sv503_minkeepsearch = i->info503->minkeepsearch; + i503.sv503_maxkeepsearch = i->info503->maxkeepsearch; + i503.sv503_minkeepcomplsearch = i->info503->minkeepcomplsearch; + i503.sv503_maxkeepcomplsearch = i->info503->maxkeepcomplsearch; + i503.sv503_threadcountadd = i->info503->threadcountadd; + i503.sv503_numblockthreads = i->info503->numlockthreads; + i503.sv503_scavtimeout = i->info503->scavtimeout; + i503.sv503_minrcvqueue = i->info503->minrcvqueue; + i503.sv503_minfreeworkitems = i->info503->minfreeworkitems; + i503.sv503_xactmemsize = i->info503->xactmemsize; + i503.sv503_threadpriority = i->info503->threadpriority; + i503.sv503_maxmpxct = i->info503->maxmpxct; + i503.sv503_oplockbreakwait = i->info503->oplockbreakwait; + i503.sv503_oplockbreakresponsewait = i->info503->oplockbreakresponsewait; + i503.sv503_enableoplocks = i->info503->enableoplocks; + i503.sv503_enableoplockforceclose = i->info503->enableoplockforceclose; + i503.sv503_enablefcbopens = i->info503->enablefcbopens; + i503.sv503_enableraw = i->info503->enableraw; + i503.sv503_enablesharednetdrives = i->info503->enablesharednetdrives; + i503.sv503_minfreeconnections = i->info503->minfreeconnections; + i503.sv503_maxfreeconnections = i->info503->maxfreeconnections; + + ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_503, i503, + (struct SERVER_INFO_503 **)buffer, + &num_info); + break; + + case 598: + ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_598, i598, + (struct SERVER_INFO_598 **)buffer, + &num_info); + break; + + case 599: + ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_599, i599, + (struct SERVER_INFO_599 **)buffer, + &num_info); + break; + case 1005: i1005.sv1005_comment = talloc_strdup(mem_ctx, i->info1005->comment); @@ -174,6 +441,9 @@ WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx, case 100: case 101: case 102: + case 402: + case 502: + case 503: case 1005: break; default: diff --git a/source3/lib/netapi/tests/Makefile.in b/source3/lib/netapi/tests/Makefile.in index 659f82c9d8..ddf4af5d0c 100644 --- a/source3/lib/netapi/tests/Makefile.in +++ b/source3/lib/netapi/tests/Makefile.in @@ -44,7 +44,7 @@ bin/.dummy: CMDLINE_OBJ = common.o NETAPIBUFFER_OBJ = netapibuffer.o -NETAPITEST_OBJ = netapitest.o netlocalgroup.o netuser.o netgroup.o netdisplay.o netshare.o netfile.o $(CMDLINE_OBJ) +NETAPITEST_OBJ = netapitest.o netlocalgroup.o netuser.o netgroup.o netdisplay.o netshare.o netfile.o netserver.o $(CMDLINE_OBJ) bin/netapitest@EXEEXT@: $(BINARY_PREREQS) $(NETAPITEST_OBJ) @echo Linking $@ diff --git a/source3/lib/netapi/tests/common.h b/source3/lib/netapi/tests/common.h index 9320840909..7e05aaf657 100644 --- a/source3/lib/netapi/tests/common.h +++ b/source3/lib/netapi/tests/common.h @@ -43,6 +43,8 @@ NET_API_STATUS netapitest_share(struct libnetapi_ctx *ctx, const char *hostname); NET_API_STATUS netapitest_file(struct libnetapi_ctx *ctx, const char *hostname); +NET_API_STATUS netapitest_server(struct libnetapi_ctx *ctx, + const char *hostname); #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) diff --git a/source3/lib/netapi/tests/netapitest.c b/source3/lib/netapi/tests/netapitest.c index 4a38f721d8..00e5b2ae40 100644 --- a/source3/lib/netapi/tests/netapitest.c +++ b/source3/lib/netapi/tests/netapitest.c @@ -89,6 +89,11 @@ int main(int argc, const char **argv) goto out; } + status = netapitest_server(ctx, hostname); + if (status) { + goto out; + } + out: if (status != 0) { printf("testsuite failed with: %s\n", diff --git a/source3/lib/netapi/tests/netserver.c b/source3/lib/netapi/tests/netserver.c new file mode 100644 index 0000000000..f7b9286be6 --- /dev/null +++ b/source3/lib/netapi/tests/netserver.c @@ -0,0 +1,61 @@ +/* + * Unix SMB/CIFS implementation. + * NetServer testsuite + * Copyright (C) Guenther Deschner 2008 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses/>. + */ + +#include <sys/types.h> +#include <inttypes.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <netapi.h> + +#include "common.h" + +NET_API_STATUS netapitest_server(struct libnetapi_ctx *ctx, + const char *hostname) +{ + NET_API_STATUS status = 0; + uint32_t levels[] = { 100, 101, 102, 402, 403, 502, 503, 1005 }; + int i; + + printf("NetServer tests\n"); + + /* basic queries */ + for (i=0; i<ARRAY_SIZE(levels); i++) { + uint8_t *buffer = NULL; + printf("testing NetServerGetInfo level %d\n", levels[i]); + + status = NetServerGetInfo(hostname, levels[i], &buffer); + if (status && status != 124) { + NETAPI_STATUS(ctx, status, "NetServerGetInfo"); + goto out; + } + } + + status = 0; + + printf("NetServer tests succeeded\n"); + out: + if (status != 0) { + printf("NetServer testsuite failed with: %s\n", + libnetapi_get_error_string(ctx, status)); + } + + return status; +} diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 78431d93c8..b9a7f8788d 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1051,17 +1051,17 @@ static void open_socket_out_connected(struct async_req *subreq) subreq->async.priv, struct async_req); struct open_socket_out_state *state = talloc_get_type_abort( req->private_data, struct open_socket_out_state); - NTSTATUS status; + int err; int sys_errno; - status = async_connect_recv(subreq, &sys_errno); + err = async_connect_recv(subreq, &sys_errno); TALLOC_FREE(subreq); - if (NT_STATUS_IS_OK(status)) { + if (err == 0) { async_req_done(req); return; } - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) + if ((sys_errno == ETIME) || (sys_errno == EINPROGRESS) || (sys_errno == EALREADY) || (sys_errno == EAGAIN)) { @@ -1082,7 +1082,7 @@ static void open_socket_out_connected(struct async_req *subreq) } if (!async_req_set_timeout(subreq, state->ev, timeval_set(0, state->wait_nsec))) { - async_req_nterror(req, NT_STATUS_NO_MEMORY); + async_req_error(req, ENOMEM); return; } subreq->async.fn = open_socket_out_connected; @@ -1098,17 +1098,17 @@ static void open_socket_out_connected(struct async_req *subreq) #endif /* real error */ - async_req_nterror(req, map_nt_error_from_unix(sys_errno)); + async_req_error(req, sys_errno); } NTSTATUS open_socket_out_recv(struct async_req *req, int *pfd) { struct open_socket_out_state *state = talloc_get_type_abort( req->private_data, struct open_socket_out_state); - NTSTATUS status; + int err; - if (async_req_is_nterror(req, &status)) { - return status; + if (async_req_is_errno(req, &err)) { + return map_nt_error_from_unix(err); } *pfd = state->fd; state->fd = -1; diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index b56c0fd4d3..9bf6f29105 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "winbindd/winbindd.h" +#include "wbc_async.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND @@ -32,6 +32,57 @@ struct req_read_state { int fd; }; +bool async_req_is_wbcerr(struct async_req *req, wbcErr *pwbc_err) +{ + enum async_req_state state; + uint64_t error; + if (!async_req_is_error(req, &state, &error)) { + *pwbc_err = WBC_ERR_SUCCESS; + return false; + } + + switch (state) { + case ASYNC_REQ_USER_ERROR: + *pwbc_err = error; + break; + case ASYNC_REQ_TIMED_OUT: + *pwbc_err = WBC_ERR_UNKNOWN_FAILURE; + break; + case ASYNC_REQ_NO_MEMORY: + *pwbc_err = WBC_ERR_NO_MEMORY; + break; + default: + *pwbc_err = WBC_ERR_UNKNOWN_FAILURE; + break; + } + return true; +} + +wbcErr map_wbc_err_from_errno(int error) +{ + switch(error) { + case EPERM: + case EACCES: + return WBC_ERR_AUTH_ERROR; + case ENOMEM: + return WBC_ERR_NO_MEMORY; + case EIO: + default: + return WBC_ERR_UNKNOWN_FAILURE; + } +} + +wbcErr async_req_simple_recv_wbcerr(struct async_req *req) +{ + wbcErr wbc_err; + + if (async_req_is_wbcerr(req, &wbc_err)) { + return wbc_err; + } + + return WBC_ERR_SUCCESS; +} + static void wb_req_read_len(struct async_req *subreq); static void wb_req_read_main(struct async_req *subreq); static void wb_req_read_extra(struct async_req *subreq); @@ -76,12 +127,13 @@ static void wb_req_read_len(struct async_req *subreq) subreq->async.priv, struct async_req); struct req_read_state *state = talloc_get_type_abort( req->private_data, struct req_read_state); - NTSTATUS status; + int err; + ssize_t ret; - status = recvall_recv(subreq); + ret = recvall_recv(subreq, &err); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (ret < 0) { + async_req_error(req, map_wbc_err_from_errno(err)); return; } @@ -89,7 +141,7 @@ static void wb_req_read_len(struct async_req *subreq) DEBUG(0, ("wb_req_read_len: Invalid request size received: " "%d (expected %d)\n", (int)state->wb_req->length, (int)sizeof(struct winbindd_request))); - async_req_nterror(req, NT_STATUS_INVALID_BUFFER_SIZE); + async_req_error(req, WBC_ERR_INVALID_RESPONSE); return; } @@ -110,12 +162,13 @@ static void wb_req_read_main(struct async_req *subreq) subreq->async.priv, struct async_req); struct req_read_state *state = talloc_get_type_abort( req->private_data, struct req_read_state); - NTSTATUS status; + int err; + ssize_t ret; - status = recvall_recv(subreq); + ret = recvall_recv(subreq, &err); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (ret < 0) { + async_req_error(req, map_wbc_err_from_errno(err)); return; } @@ -124,7 +177,7 @@ static void wb_req_read_main(struct async_req *subreq) DEBUG(3, ("Got request with %d bytes extra data on " "unprivileged socket\n", (int)state->wb_req->extra_len)); - async_req_nterror(req, NT_STATUS_INVALID_BUFFER_SIZE); + async_req_error(req, WBC_ERR_INVALID_RESPONSE); return; } @@ -156,30 +209,31 @@ static void wb_req_read_extra(struct async_req *subreq) { struct async_req *req = talloc_get_type_abort( subreq->async.priv, struct async_req); - NTSTATUS status; + int err; + ssize_t ret; - status = recvall_recv(subreq); + ret = recvall_recv(subreq, &err); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (ret < 0) { + async_req_error(req, map_wbc_err_from_errno(err)); return; } async_req_done(req); } -NTSTATUS wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, - struct winbindd_request **preq) +wbcErr wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, + struct winbindd_request **preq) { struct req_read_state *state = talloc_get_type_abort( req->private_data, struct req_read_state); - NTSTATUS status; + wbcErr wbc_err; - if (async_req_is_nterror(req, &status)) { - return status; + if (async_req_is_wbcerr(req, &wbc_err)) { + return wbc_err; } *preq = talloc_move(mem_ctx, &state->wb_req); - return NT_STATUS_OK; + return WBC_ERR_SUCCESS; } struct req_write_state { @@ -227,12 +281,13 @@ static void wb_req_write_main(struct async_req *subreq) subreq->async.priv, struct async_req); struct req_write_state *state = talloc_get_type_abort( req->private_data, struct req_write_state); - NTSTATUS status; + int err; + ssize_t ret; - status = sendall_recv(subreq); + ret = sendall_recv(subreq, &err); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (ret < 0) { + async_req_error(req, map_wbc_err_from_errno(err)); return; } @@ -256,21 +311,22 @@ static void wb_req_write_extra(struct async_req *subreq) { struct async_req *req = talloc_get_type_abort( subreq->async.priv, struct async_req); - NTSTATUS status; + int err; + ssize_t ret; - status = sendall_recv(subreq); + ret = sendall_recv(subreq, &err); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (ret < 0) { + async_req_error(req, map_wbc_err_from_errno(err)); return; } async_req_done(req); } -NTSTATUS wb_req_write_recv(struct async_req *req) +wbcErr wb_req_write_recv(struct async_req *req) { - return async_req_simple_recv_ntstatus(req); + return async_req_simple_recv_wbcerr(req); } struct resp_read_state { @@ -322,12 +378,13 @@ static void wb_resp_read_len(struct async_req *subreq) subreq->async.priv, struct async_req); struct resp_read_state *state = talloc_get_type_abort( req->private_data, struct resp_read_state); - NTSTATUS status; + int err; + ssize_t ret; - status = recvall_recv(subreq); + ret = recvall_recv(subreq, &err); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (ret < 0) { + async_req_error(req, map_wbc_err_from_errno(err)); return; } @@ -336,7 +393,7 @@ static void wb_resp_read_len(struct async_req *subreq) "%d (expected at least%d)\n", (int)state->wb_resp->length, (int)sizeof(struct winbindd_response))); - async_req_nterror(req, NT_STATUS_INVALID_BUFFER_SIZE); + async_req_error(req, WBC_ERR_INVALID_RESPONSE); return; } @@ -357,13 +414,14 @@ static void wb_resp_read_main(struct async_req *subreq) subreq->async.priv, struct async_req); struct resp_read_state *state = talloc_get_type_abort( req->private_data, struct resp_read_state); - NTSTATUS status; + int err; + ssize_t ret; size_t extra_len; - status = recvall_recv(subreq); + ret = recvall_recv(subreq, &err); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (ret < 0) { + async_req_error(req, map_wbc_err_from_errno(err)); return; } @@ -395,30 +453,31 @@ static void wb_resp_read_extra(struct async_req *subreq) { struct async_req *req = talloc_get_type_abort( subreq->async.priv, struct async_req); - NTSTATUS status; + int err; + ssize_t ret; - status = recvall_recv(subreq); + ret = recvall_recv(subreq, &err); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (ret < 0) { + async_req_error(req, map_wbc_err_from_errno(err)); return; } async_req_done(req); } -NTSTATUS wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, - struct winbindd_response **presp) +wbcErr wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, + struct winbindd_response **presp) { struct resp_read_state *state = talloc_get_type_abort( req->private_data, struct resp_read_state); - NTSTATUS status; + wbcErr wbc_err; - if (async_req_is_nterror(req, &status)) { - return status; + if (async_req_is_wbcerr(req, &wbc_err)) { + return wbc_err; } *presp = talloc_move(mem_ctx, &state->wb_resp); - return NT_STATUS_OK; + return WBC_ERR_SUCCESS; } struct resp_write_state { @@ -466,12 +525,13 @@ static void wb_resp_write_main(struct async_req *subreq) subreq->async.priv, struct async_req); struct resp_write_state *state = talloc_get_type_abort( req->private_data, struct resp_write_state); - NTSTATUS status; + int err; + ssize_t ret; - status = sendall_recv(subreq); + ret = sendall_recv(subreq, &err); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (ret < 0) { + async_req_error(req, map_wbc_err_from_errno(err)); return; } @@ -496,19 +556,20 @@ static void wb_resp_write_extra(struct async_req *subreq) { struct async_req *req = talloc_get_type_abort( subreq->async.priv, struct async_req); - NTSTATUS status; + int err; + ssize_t ret; - status = sendall_recv(subreq); + ret = sendall_recv(subreq, &err); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (err < 0) { + async_req_error(req, map_wbc_err_from_errno(err)); return; } async_req_done(req); } -NTSTATUS wb_resp_write_recv(struct async_req *req) +wbcErr wb_resp_write_recv(struct async_req *req) { - return async_req_simple_recv_ntstatus(req); + return async_req_simple_recv_wbcerr(req); } diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index ae9a034cc8..4d3a609530 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -18,8 +18,7 @@ */ #include "includes.h" -#include "winbindd/winbindd.h" -#include "winbindd/winbindd_proto.h" +#include "wbc_async.h" static int make_nonstd_fd(int fd) { @@ -131,12 +130,6 @@ static bool winbind_closed_fd(int fd) return false; } -struct wb_context { - struct async_req_queue *queue; - int fd; - bool is_priv; -}; - struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx) { struct wb_context *result; @@ -163,7 +156,7 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, struct sockaddr_un sunaddr; struct stat st; char *path = NULL; - NTSTATUS status; + wbcErr wbc_err; if (wb_ctx->fd != -1) { close(wb_ctx->fd); @@ -173,13 +166,13 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, /* Check permissions on unix socket directory */ if (lstat(dir, &st) == -1) { - status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + wbc_err = WBC_ERR_WINBIND_NOT_AVAILABLE; goto post_status; } if (!S_ISDIR(st.st_mode) || (st.st_uid != 0 && st.st_uid != geteuid())) { - status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + wbc_err = WBC_ERR_WINBIND_NOT_AVAILABLE; goto post_status; } @@ -202,13 +195,13 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, if ((lstat(sunaddr.sun_path, &st) == -1) || !S_ISSOCK(st.st_mode) || (st.st_uid != 0 && st.st_uid != geteuid())) { - status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + wbc_err = WBC_ERR_WINBIND_NOT_AVAILABLE; goto post_status; } wb_ctx->fd = make_safe_fd(socket(AF_UNIX, SOCK_STREAM, 0)); if (wb_ctx->fd == -1) { - status = map_nt_error_from_unix(errno); + wbc_err = map_wbc_err_from_errno(errno); goto post_status; } @@ -226,24 +219,22 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, return req; nomem: - status = NT_STATUS_NO_MEMORY; + wbc_err = WBC_ERR_NO_MEMORY; post_status: req = async_req_new(mem_ctx); if (req == NULL) { return NULL; } - if (async_post_ntstatus(req, ev, status)) { + if (async_post_error(req, ev, wbc_err)) { return req; } TALLOC_FREE(req); return NULL; } -static NTSTATUS wb_connect_recv(struct async_req *req) +static wbcErr wb_connect_recv(struct async_req *req) { - int dummy; - - return async_connect_recv(req, &dummy); + return async_req_simple_recv_wbcerr(req); } static struct winbindd_request *winbindd_request_copy( @@ -295,8 +286,8 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, } if (winbind_closed_fd(fd)) { - if (!async_post_ntstatus(result, ev, - NT_STATUS_PIPE_DISCONNECTED)) { + if (!async_post_error(result, ev, + WBC_ERR_WINBIND_NOT_AVAILABLE)) { goto fail; } return result; @@ -329,18 +320,18 @@ static void wb_int_trans_write_done(struct async_req *subreq) subreq->async.priv, struct async_req); struct wb_int_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_int_trans_state); - NTSTATUS status; + wbcErr wbc_err; - status = wb_req_write_recv(subreq); + wbc_err = wb_req_write_recv(subreq); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (!WBC_ERROR_IS_OK(wbc_err)) { + async_req_error(req, wbc_err); return; } subreq = wb_resp_read_send(state, state->ev, state->fd); if (subreq == NULL) { - async_req_nterror(req, NT_STATUS_NO_MEMORY); + async_req_error(req, WBC_ERR_NO_MEMORY); } subreq->async.fn = wb_int_trans_read_done; subreq->async.priv = req; @@ -352,32 +343,32 @@ static void wb_int_trans_read_done(struct async_req *subreq) subreq->async.priv, struct async_req); struct wb_int_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_int_trans_state); - NTSTATUS status; + wbcErr wbc_err; - status = wb_resp_read_recv(subreq, state, &state->wb_resp); + wbc_err = wb_resp_read_recv(subreq, state, &state->wb_resp); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (!WBC_ERROR_IS_OK(wbc_err)) { + async_req_error(req, wbc_err); return; } async_req_done(req); } -static NTSTATUS wb_int_trans_recv(struct async_req *req, - TALLOC_CTX *mem_ctx, - struct winbindd_response **presponse) +static wbcErr wb_int_trans_recv(struct async_req *req, + TALLOC_CTX *mem_ctx, + struct winbindd_response **presponse) { struct wb_int_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_int_trans_state); - NTSTATUS status; + wbcErr wbc_err; - if (async_req_is_nterror(req, &status)) { - return status; + if (async_req_is_wbcerr(req, &wbc_err)) { + return wbc_err; } *presponse = talloc_move(mem_ctx, &state->wb_resp); - return NT_STATUS_OK; + return WBC_ERR_SUCCESS; } static const char *winbindd_socket_dir(void) @@ -448,13 +439,13 @@ static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq) subreq->async.priv, struct async_req); struct wb_open_pipe_state *state = talloc_get_type_abort( req->private_data, struct wb_open_pipe_state); - NTSTATUS status; + wbcErr wbc_err; - status = wb_connect_recv(subreq); + wbc_err = wb_connect_recv(subreq); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { + if (!WBC_ERROR_IS_OK(wbc_err)) { state->wb_ctx->is_priv = true; - async_req_nterror(req, status); + async_req_error(req, wbc_err); return; } @@ -478,12 +469,12 @@ static void wb_open_pipe_ping_done(struct async_req *subreq) struct wb_open_pipe_state *state = talloc_get_type_abort( req->private_data, struct wb_open_pipe_state); struct winbindd_response *wb_resp; - NTSTATUS status; + wbcErr wbc_err; - status = wb_int_trans_recv(subreq, state, &wb_resp); + wbc_err = wb_int_trans_recv(subreq, state, &wb_resp); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (!WBC_ERROR_IS_OK(wbc_err)) { + async_req_error(req, wbc_err); return; } @@ -511,12 +502,12 @@ static void wb_open_pipe_getpriv_done(struct async_req *subreq) struct wb_open_pipe_state *state = talloc_get_type_abort( req->private_data, struct wb_open_pipe_state); struct winbindd_response *wb_resp = NULL; - NTSTATUS status; + wbcErr wbc_err; - status = wb_int_trans_recv(subreq, state, &wb_resp); + wbc_err = wb_int_trans_recv(subreq, state, &wb_resp); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (!WBC_ERROR_IS_OK(wbc_err)) { + async_req_error(req, wbc_err); return; } @@ -540,21 +531,21 @@ static void wb_open_pipe_connect_priv_done(struct async_req *subreq) subreq->async.priv, struct async_req); struct wb_open_pipe_state *state = talloc_get_type_abort( req->private_data, struct wb_open_pipe_state); - NTSTATUS status; + wbcErr wbc_err; - status = wb_connect_recv(subreq); + wbc_err = wb_connect_recv(subreq); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + if (!WBC_ERROR_IS_OK(wbc_err)) { + async_req_error(req, wbc_err); return; } state->wb_ctx->is_priv = true; async_req_done(req); } -static NTSTATUS wb_open_pipe_recv(struct async_req *req) +static wbcErr wb_open_pipe_recv(struct async_req *req) { - return async_req_simple_recv_ntstatus(req); + return async_req_simple_recv_wbcerr(req); } struct wb_trans_state { @@ -631,27 +622,26 @@ struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, static bool wb_trans_retry(struct async_req *req, struct wb_trans_state *state, - NTSTATUS status) + wbcErr wbc_err) { struct async_req *subreq; - if (NT_STATUS_IS_OK(status)) { + if (WBC_ERROR_IS_OK(wbc_err)) { return false; } - if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) - || NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + if (wbc_err == WBC_ERR_WINBIND_NOT_AVAILABLE) { /* * Winbind not around or we can't connect to the pipe. Fail * immediately. */ - async_req_nterror(req, status); + async_req_error(req, wbc_err); return true; } state->num_retries -= 1; if (state->num_retries == 0) { - async_req_nterror(req, status); + async_req_error(req, wbc_err); return true; } @@ -685,7 +675,7 @@ static void wb_trans_retry_wait_done(struct async_req *subreq) ret = async_wait_recv(subreq); TALLOC_FREE(subreq); if (ret) { - async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); + async_req_error(req, WBC_ERR_UNKNOWN_FAILURE); return; } @@ -704,12 +694,12 @@ static void wb_trans_connect_done(struct async_req *subreq) subreq->async.priv, struct async_req); struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); - NTSTATUS status; + wbcErr wbc_err; - status = wb_open_pipe_recv(subreq); + wbc_err = wb_open_pipe_recv(subreq); TALLOC_FREE(subreq); - if (wb_trans_retry(req, state, status)) { + if (wb_trans_retry(req, state, wbc_err)) { return; } @@ -729,29 +719,29 @@ static void wb_trans_done(struct async_req *subreq) subreq->async.priv, struct async_req); struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); - NTSTATUS status; + wbcErr wbc_err; - status = wb_int_trans_recv(subreq, state, &state->wb_resp); + wbc_err = wb_int_trans_recv(subreq, state, &state->wb_resp); TALLOC_FREE(subreq); - if (wb_trans_retry(req, state, status)) { + if (wb_trans_retry(req, state, wbc_err)) { return; } async_req_done(req); } -NTSTATUS wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx, - struct winbindd_response **presponse) +wbcErr wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx, + struct winbindd_response **presponse) { struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); - NTSTATUS status; + wbcErr wbc_err; - if (async_req_is_nterror(req, &status)) { - return status; + if (async_req_is_wbcerr(req, &wbc_err)) { + return wbc_err; } *presponse = talloc_move(mem_ctx, &state->wb_resp); - return NT_STATUS_OK; + return WBC_ERR_SUCCESS; } |