The SNMP4J-4.2.0 release provides multi-subagent Unix transport mapping support for master- and subagent connections per master agent. In addition, agent audit policy and restricted security for sample agents have been implemented. Bug fixes for the Unix transport mapping has been applied as well.
CHANGES SNMP4J-AgentX 4.2.0
- SECURITY: Added support for agent auditing for
TestMasterAgentandTestSubagentusing anAgentPolicyProfile. - Changed:
AgentXRequest.getSecurityLevel()to returnSecurityLevel.NO_AUTH_NO_PRIVinstead of throwing anUnsupportedOperationExceptionto support agent auditing. - Changed:
TestMasterAgentnow reads configuration from a properties file instead of programmatic initialization. - Added: Support for multiple subagents through Unix domain transport mapping on a single master agent.
- Updated:
README_SECURITY.txtwith information about agent auditing.
CHANGES SNMP4J-Unix-Transport 1.2.2
- Fixed:
UnixSocketStreamTransportMappingignoredisServerEnabled()and bound its socket path even in client mode, unlikeDefaultTcpTransportMappingandTLSTM, which bind their listen address only if the server is enabled. A client mode transport mapping that opens outgoing connections only - as created for instance byAgentXSubagent.addMaster(..), which explicitly callssetServerEnabled(false)- therefore competed for the socket path of the transport mapping that serves incoming connections on it. An IP based transport mapping can bind an ephemeral port in that situation, but a Unix domain socket path is the address itself, solisten() failed with “Address already in use” as soon as both transport mappings used the same path. To keep the previous behavior for transport mappings that are used as a server, the constructor that takes a listen address enables the server mode now, as the corresponding constructor ofDefaultTcpTransportMappingdoes. Use the newUnixSocketStreamTransportMapping(UnixDomainAddress,boolean)constructor orsetServerEnabled(false)for a client mode transport mapping. - Added: A client mode
UnixSocketStreamTransportMapping(seesetServerEnabled(boolean)) binds its socket path to the outgoing socket of every connection it opens, so that the peer can tell this SNMP entity apart from other entities that connect to it. A Unix domain socket that has not been bound has no address at all, thus all peers that connect with an unbound socket are reported with the same empty address by the accepting entity, which keeps its connections in a map that is keyed by that address: only the connection that arrived last could be addressed. Several AgentX sub-agents can therefore share one Unix domain master agent now, as long as each of them uses its own socket path. If the path cannot be bound, the connection is opened with an unbound socket as before and a warning is logged, and an entity that accepts a connection from an unbound socket logs a warning as well. New API:UnixSocketStreamTransportMapping.ServerThread.bindOutgoingSocket(SocketChannel). - Fixed:
UnixSocketStreamTransportMapping.close()removed the socket file of its listen address even if it had not created that file, which could remove the socket of another SNMP entity that used the same path.
Only a socket file that this transport mapping has bound itself is removed now (see the new
removeBoundSocketFile()method and theboundSocketPathmember). close() also skipped closing the transport mapping altogether if it had no listen address. - Fixed:
UnixSocketStreamTransportMapping.listen()logged that the listen address had been bound successfully even if nothing had been bound at all, which is the case in client mode and for a transport mapping without a listen address (for example one created byGenericAddress.newLocalAddress("unix"), whose address is empty). It reports the actual outcome now. - Fixed:
UnixDomainAddress.isValid()andparseAddress(String)threw aNullPointerExceptionfor a socket path that has no parent path element, that is for a plain socket file name like “snmp4j-agent.sock” - the natural form for a socket in the working directory - as well as for the empty path and for a file system root. Such an address could therefore not be parsed at all, becauseGenericAddress.parse(String)discards an address whose parsing throws an exception.isValid()also threw aNullPointerExceptionif no socket path had been set at all. - Fixed:
UnixDomainAddress.isValid()does not check file system permissions anymore. It checks now that the socket path is not empty and that it fits into the sun_path member of the sockaddr_un structure of the operating system (see the newMAX_SOCKET_PATH_LENGTHconstant), because those are the properties of the address itself. Before, it required write and search permission on the directory of the socket path, which is what binding a socket needs but not what connecting to one needs: an existing socket in a read-only directory (for example, below /var/run) was reported as invalid, although it can be connected, whereas a socket file without write permission for the SNMP4J process was reported as valid although connecting to it fails with “Permission denied”. As a consequence, parseAddress(String) does not depend on the current working directory, on the effective user of the process, and on the state of the file system anymore. An over-long socket path is rejected now, which was accepted before, although it cannot be bound. - Fixed:
UnixDomainAddress.parseAddress(String)returns false instead of throwing anInvalidPathExceptionif the supplied address contains aNULcharacter, and false instead of throwing aNullPointerExceptionif the supplied address is null. - Added: New org.snmp4j.transport.unix.audit package with the
UnixDomainAgentProfilePolicy, a subclass of theDefaultAgentAuditPolicyof SNMP4J-Agent that supports the “unix” address domain ofUnixDomainAddress.
Because a Unix domain socket operation is always local, theInetAddressbased network access restrictions of theAgentPolicyProfileare not applicable to it and the file system access that such an operation needs is checked instead: the socket’s (local) file path is matched against the allowed files and directories of the profile, whereLISTENis checked as aCREATE,CLOSEas aDELETE,SENDas aWRITE, andRECEIVEas aREADfile operation. Transport operations of other address domains are audited by theDefaultAgentAuditPolicyunchanged. The new optional (provided) dependency to SNMP4J-Agent is required for this package only. - Added:
UnixDomainAddress.isBindable()andUnixDomainAddress.isConnectable()check whether the current process may listen on respectively send to a Unix domain socket address, using the permissions that the corresponding operation actually requires: write and search permission on the socket’s directory to bind it and write permission on the socket file to connect to it. Because both are a snapshot of the current file system state, a failing bind or connect still has to be handled. In addition,UnixDomainAddress.getParentDirectory()returns the absolute directory that contains the socket file andUnixDomainAddress.MAX_SOCKET_PATH_LENGTHprovides the maximum length of a Unix domain socket path in bytes. - Updated: Dependency to SNMP4J to 3.13.1 and SNMP4J-Agent to 3.10.1.