summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-06-12Archiving NoticeHEADmainStewart Blacklock1-0/+5
2022-05-04Include fstream (#7)jmbills2-0/+2
Missing the fstream include is causing build errors that block the upstream sync, so adding it to fix the build. Tested: Confirmed that it builds. Signed-off-by: Jason M. Bills <jason.m.bills@intel.com>
2022-03-15Make mount/unmount dbus calls asynchronousPrzemyslaw Czarnowski8-128/+186
Change the default behavior of mount/umount dbus calls from blocking to unblocking ones. Once mount/unmount is triggered, appropriate action is running in the background moving handling of operation result to async event. At the end of processing dbus completion signal is sent to client with uint value of operation status (identical with errno code). Tested: Manual scheduling of mount and unmount operations with monitoring dbus communication of virtual-media service - matching api calls with completion signal. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
2022-02-14Switch the build system to mesonPrzemyslaw Czarnowski18-41/+666
Due to requirements from community, new projects have to be built with meson. To unify with other projects some additional warnings has been enabled, so appropriate code updates has been implemented. This commit makes both meson and CMake available to simplyfy transition in openbmc. CMake support will be removed after switching to meson in openbmc will be accepted. Tested: Compiled and smoke tested. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
2022-02-07Force udev change event on init (#6)Michal Orzel2-2/+29
* Force udev change event on init This change provides temporary workaround for HSD HSD18020136609 ("Can not mount image using Virtual media and CIFS protocol"). When in initial state, additional udev change event is triggered for all NBD devices, which prevents from disconnection on first mount attempt after reboot. The actual issue is a regression, introduced after kernel update from 5.10.67 to 5.14.11. The exact source in kernel is yet to be located; after that an actual fix shall be provided and this change will be reverted. Abstracts echoToFile to a separate class, that may be used by other classes through inheritance. This way, writing to udev files can be handled by different object than UsbGadget. Tested: Successful mounts after reboot for all supported methods (Proxy, Legacy HTTPS, Legacy CIFS). Change-Id: I2ceb826c73b6e46938397060877d35a9fa1c0e03 Signed-off-by: MichalX Orzel <michalx.orzel@intel.com>
2022-01-26Add -Wextra, remove warnings (#1)Przemyslaw Czarnowski7-32/+52
Removed all -Wextra warnings in VM sources. -Wno-unused-parameter has to be disabled due to lots of such warnings in sdbusplus. Tested: Compilation generates no warnings Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-11-19virtual-media: CMake updateCzarnowski, Przemyslaw2-18/+34
- Fixed standalone builds: - added boost to standalone build, - sdbusplus version bumped up (for dbus signal support) - Fixed warnings when finding udev. Tested: Standalone compilation works in "clean" system, yocto compiles without regression. Change-Id: Iddaa980ec2d299ff836d2e06970ebc5a5b1cf3d9 Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-11-16virtual-media: Replace tmpnam with mkstempPrzemyslaw Czarnowski1-16/+39
In the mechanism of passing the password to client application a file with password is used. Until now, the file has been created with use of unsecure tmpnam function, which can be a subject of TOCTOU vulnerability. Changing tmpnam to mkstemp required some changes in the flow (std::fstream can't reuse file descriptor of opened file, appropriate file permissions are set by mkstemp). Tested: Manually. Password is passed to nbdkit, temporary file permissions are the same as before. Change-Id: Icdd1719cafa08946d5b06414a0db7fa4714cb7ee Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-11-10virtual-media: Fix samba mount with latest kernelCzarnowski, Przemyslaw1-3/+3
Latest changes in kernel introduces changes in mounting parameters. - nolock parameter is no longer used with cifs (before it was ignored) - shortened user version of username is no longer valid (even though it still in the codebase) Tested: Updated mount parameter list made CIFS mount possible again Change-Id: I0f0ecb1f3cdb19144246340e5df12203648648f5 Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-10-28Cleanup mounted resources after application crash.Krzysztof Richert2-5/+67
On initial state application cleans mounted resources which were allocated by user befor application crashed. Without that busy slot is not avaialble anymore for user. Tested: 1. Mount CIFS share. 2. Send terminate signal to virtual-media (kill -9). 3. Mount CIFS share on the same slot as during step 1. Change-Id: I7088e94832fb7bec171a56f73bd66cd29e9b246f Signed-off-by: Krzysztof Richert <krzysztof.richert@intel.com>
2021-10-25Added README.md fileCzarnowski, Przemyslaw1-0/+111
Adding some README information for Virtual Media service. Change-Id: I34a87e369e8f715c2e6bcd1762517231b903af9a Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-08-27Override default libcurl CAInfo with empty string.Golgowski, Wiktor1-13/+13
This change allows virtual-media to pass a zero-length string to nbdkit curl plugin cainfo parameter, which will allow for capath to be used. Tested: Manually, with Virtual-Media HTTPS test in ATF. Change-Id: I14ffa2ecbb2bd6cadee3bb8929ef2e1b8bbbf157 Signed-off-by: Golgowski, Wiktor <wiktor.golgowski@intel.com>
2021-08-25Restricted TLS cipher suites to preferred onesKarol Niczyj1-4/+5
Updated TLS 1.2 cipher list and added TLS1.3 cipher list. Tested by Oleksandr Shulzhenko on local setup. Change-Id: I218c245d8ddf7e54dae258a39cd78c3255027b6e Signed-off-by: Karol Niczyj <karol.niczyj@intel.com>
2021-05-25Forbid ECDHE-RSA-CHACHA20-POLY1305 with TLSv1.2Czarnowski, Przemyslaw1-1/+2
According to the latest recommendations obsolete cipher suites shall be forbidden. Tested: Python HTTP server configured TLSv1.2 with ECDHE-RSA-CHACHA20-POLY1305 cipher can't be reached. Change-Id: I370c125b28c4df4bba744ec63536aa8fdebb961d Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-05-24Forbid redirection of https resourcesCzarnowski, Przemyslaw1-0/+1
Due to security reasons (by security researcher recommendation) remote source redirections shouldn't be allowed in order to disallow connection downgrading Tested: Tested with python server script forcing redirection Change-Id: Ia68884dbcc399abc685dcbcf4e205aa62356478f Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-05-20Validate user name for CIFSCzarnowski, Przemyslaw2-3/+15
Providing comma (,) in username can lead to inject some unappropriate mount options. In opposite to password, username is not escaped by kernel driver so we have to disallow such entries. Tested: Manually mounting CIFS share with comma Change-Id: I20ff5089d04f07d7e6aa3190fe83babdd7acfe96 Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-05-07Legacy HTTPs: Set minimum tls version to 1.2Czarnowski, Przemyslaw1-1/+1
Due to change of recommendation of minimum TLS version from 1.1 to 1.2, version passed to CURL plugin of Nbdkit is changed appropriately. Tested: Manually; TLSv1.1 server is rejected for Legacy/HTTPs. Change-Id: Ifc8848817deb9f73a44f551d85f1fe9ba20b3e10 Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-05-06Change log level to InfoCzarnowski, Przemyslaw7-21/+20
Due to security reasons "user/username" has to be removed from the information that is logged by application. Sensitive data has been moved to "Debug"" level (lowest one) and default one has moved one level up to "Info". Also some important information allowing to catch basic errors has been upgraded to "Info". Tested: Manually, mounting both Legacy mode remote types (HTTPs and CIFS) and checking if journal for VirtualMedia service does not contain sensitive information. Change-Id: Ie6c3a79c94637e3632af76daf957e986b2dd3b6d Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-05-06Moving sockets from /tmp to /runCzarnowski, Przemyslaw3-73/+47
Socket files needed to serve virtual media devices are created in /tmp directory which is temporary tmpfs mount. All temporary directories are subject of systemd's systemd-tmpfiles-clean.service which cleanes up them basing on age. Systemd-tmpfiles-clean uses tmpfiles.d entries to manage all temporary directories. This change moves creation of VM socket directory to tmpfiles.d - appropriate config has been added for Virtual Media. The entry will create socket directory without Age limitation. Socket location is moved from /tmp to /run. Is it more appropriate place where all daemons should have it's working files located. Tested: Manually mounting proxy and legacy cifs/https share, running systemd-tmpfiles-clean.service does not render any problems. Change-Id: I29ace61894587e03449e29c2459930008a2a1d99 Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-04-27Escape cifs credentials to prevent injectionCzarnowski, Przemyslaw2-0/+32
Mount function consumes mount parameters as coma delimited options. In order to make it resistant to classic parameter injection each comma in username or password parameter that user provides is escaped by second comma character. This fix appiles such escaping for samba credentials. Tested: Tested by inserting media with password=smbpass,ver=1.0. Kernel does not mount share, showing error appropriate to incorrect credentials: intel-obmc kernel: CIFS: Status code returned 0xc000006d \ STATUS_LOGON_FAILURE Change-Id: I3acb24a4b24e798e54e095c69e9c6ec3151e03d1 Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-04-27Image mount fails if socket directory not presentAnna Platash1-0/+31
When trying to mount virtual media image in Legacy mode nbd tries to create unix socket and if the parent directory does not exist mount fails. Also used noexcept versions of filesystem operations. Tested: Locally, by manually removing the socket's parent folder and mounting an image in Legacy mode (Samba). Change-Id: If5beb7add655e09a60511b30e4edbd34c8c15ec5 Signed-off-by: Anna Platash <anna.platash@intel.com> Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-04-22Remove samba mount parameters loggingCzarnowski, Przemyslaw1-1/+0
SMB share when mounted leaved a trace in journal with parameters passed with mount command. Among others password and user name has been included what raises security issue. Tested: Manually, SMB mount does not reveal share credentials in logs any more Change-Id: I30abbe085620c95d42b19f19d94285a211024cf4 Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-04-14Invalid HTTP return codes in RemoteMedia in Legacy mode.Alicja Rybak2-0/+12
Invalid status code 500 when slot is inserted twice. Invalid status code 200 when slot is ejected twice. In both situation code 403 should be returned. Using [[noreturn]] attribute for handleEvent functions. Tested: Manually on hw and verified that status code is 403. Change-Id: I886c41048d6bcfcb3d47b46fd23a2de564d9dd3e Signed-off-by: Alicja Rybak <alicja.rybak@intel.com>
2021-01-11WriteProtected value uses reversed logicAnna Platash1-1/+1
When mounting image with WriteProtected set to true, it is shown to be false and vice versa. Change-Id: Id5ff0f0deb5d5822279dd02af0deeb7586dcd065 Signed-off-by: Anna Platash <anna.platash@intel.com>
2020-12-15Remove unsuported cipher suits form legacy HTTPSKarol Wachowski1-1/+4
Removed following cipher suits: * AES256-GCM-SHA384 * AES128-GCM-SHA256 * AES256-SHA256 * AES128-SHA256 Tested: - verified manually that listed ciphers are not accepted - verified manually that it is possible to mount HTTPS resource using TLS version >= 1.1 and other ciphers Change-Id: If41dfc8fa8439a1be1fd61dbb639595523a7157d Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
2020-11-06Virtual Media does not propagate informationAnna Platash1-0/+10
between Redfish and Web UI WriteProtected field was not updated in bmcweb. Added new property WriteProtected to MountPoint interface to allow bmcweb updating the WriteProtected field value properly. Tested on manually on ArcherCity by mounting images via RedFish interface with and without write protection. Change-Id: I9f642ace2462c52bf964d2e54b0f59fac1b06738 Signed-off-by: Anna Platash <anna.platash@intel.com>
2020-10-28Allow for negotiation of higher SMB versionAnna Platash1-10/+31
SMB 3.1.1 provides more secure authentication. vers=3 is preferred over vers=3.0 as it automatically negotiates 3.0 or 3.0.2 dialects, if available from server. While the vers=3.0 uses only 3.0. Fallback scheme: try vers=3.1.1 if fails - try vers=3 if fails - unrecoverable error path Tested: Manually on ArcherCity. Mounting .iso image in legacy mode (smb), using RedFish interface. Change-Id: Ief224353079f1b7200011a00b8d5c482f57f844e Signed-off-by: Anna Platash <anna.platash@intel.com>
2020-10-02Add requirement for TLSv1.1 for VM legacy mode.Golgowski, Wiktor1-1/+2
This change adds nbdkit curl plugin parameters for specifying TLS version. VM is configured to support TLSv1.1 or greater. Tested: manually, TLSv1.0 is not negotiated during connection. Change-Id: I0d1186534ba3ec2f7937fea65c0cc1f01557cf6e Signed-off-by: Golgowski, Wiktor <wiktor.golgowski@intel.com>
2020-09-30Revert "Add TLS version and cipher suites to legacy HTTPS."Feist, James1-6/+1
This reverts commit b253675eb507f07f8072b287c0ea68448808eb0b. Change-Id: I29c2eb73ecc37e47c4dd44b668c6d9a1ab2f6579 Signed-off-by: James Feist <james.feist@linux.intel.com>
2020-09-23Add TLS version and cipher suites to legacy HTTPS.Golgowski, Wiktor1-3/+8
This change adds nbdkit curl plugin parameters for specifying TLS version and not allowed cipher suites (OWASP recommendation). Tested: manually, TLSv1.0 is not negotiated during connection. Awaiting confirmation for cipher suites. Warning: this change may break legacy mode, if used with nbdkit without ssl-version and ssl-cipher-list (see review #272350). Change-Id: I06c5acc7a87de6c1bd1b0cdcef2af8585a3da965 Signed-off-by: Golgowski, Wiktor <wiktor.golgowski@intel.com>
2020-08-06Fix false positive mount result when in active stateKarol Wachowski1-3/+4
Tested: - verified that mount attempt in active state returns operation not supported (EOPNOTSUPP) error Signed-off-by: Karol Wachowski <karol.wachowski@intel.com> Change-Id: I3d148a6f360e4ede996f99827185ae653e0ed5c5
2020-07-28Add missing "ImageURL" property to MountPoint interfaceWludzik, Jozef1-6/+20
It fixes problem with missing information on VirtualMedia Redfish resource after user mounts media using legacy method. Part of VirtualMedia Redfish resource after fix: { ... "ConnectedVia": "URI", "Id": "Slot_2", "Image": null, "ImageName": "smb://127.0.0.1/public/openSUSE-15.1-x86_64.iso", "Inserted": true, ... } Tested: - Mounted and ejected media using legacy method with success. - Received proper details about mounted image from Redfish. Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com> Change-Id: I445b37aac27dd290ce07f589834c0a6a10d2ceef
2020-07-24VirtualMedia throw EBUSY exception when receive invalid event inKarol Wachowski3-31/+8
actiavting/deactivating states Previously mount/unmount waited until timeout occurs, when operation was already process it could finish before the timeout causing mount/unmount to get false positive/negative results. Tested: - Mount/Unmount dbus calls cause EBUSY exception in actiavting/deactivating states Change-Id: Idaacde212531c963aec304ac87e536d014d9d8d2 Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
2020-07-23Assure rigth permissions for filesCzarnowski, Przemyslaw3-4/+26
According to security guidelines, files created by service must be limited to the narrowest set of permissions required. This must be also true for 3rd party files used by Virtual Media. - For all regular files and directories created by service umask is used. - For sockets, permissions are limited by permissions of parent directory. For full reference see man unix(7). Below the most important fragment: "In the Linux implementation, sockets which are visible in the filesystem honor the permissions of the directory they are in. Their owner, group and their permissions can be changed. Creation of a new socket will fail if the process does not have write and search (execute) permission on the directory the socket is created in. Connecting to the socket object requires read/write permission. This behavior differs from many BSD-derived systems which ignore permissions for UNIX domain sockets. Portable programs should not rely on this feature for security." Change-Id: I22ff531c96c8a6903fecb5d8cc71caf33150a713 Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2020-07-21Increase device timeout for legacy mode.Czarnowski, Przemyslaw1-2/+2
For slow nbd devices (where backend is slow like https) sometimes single burst of data coudn't be read/written within default 30s timeout. Suggested timeout for such devices is > 60. 90 seconds seems safe here. This value is just a recommenation, this can be changed for specific environment. Tested: Multiple write/delete operations on mounted device. Change-Id: Idad644f7d12d346145b86c8954f271b4c3290e84 Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2020-07-21VirtualMedia add Mount/Unmount timeout handlingKarol Wachowski2-14/+12
Added Timeout dbus property for block devices in VirtualMedia. Added throwing EBUSY exception when Mount/Unmount operation times out. Added transition from ActivatingState to DeactivatingState. Tested: Verified that after mounting non-existing HTTPS resource in proxy mode, VirtualMedia recovers restoring ready state and throws EBUSY during that transition. Verfied that resources can be mounter/unmounted in both legacy and proxy mode. Change-Id: I3768af13663046cc55976ad59062f8bc1d6396ba Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
2020-07-20Provide nbdkit with path to CA certificatesCzarnowski, Przemyslaw1-1/+3
OpenBMC uses custom path for certificates: /etc/ssl/certs not /usr/lib/ssl/certs like curl plugin default. We need to provide it in order to make curl plugin work in OpenBMC environment. Tested: Certificate Authority added with UI allows to use https server signed with this certificate. Change-Id: I702179862e9e977efd162bdf19426208c4ce45f0 Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
2020-07-17Fixing multiple problems with state machine in virtual mediaKrzysztof Grobelny17-1130/+1466
- Previously machine did not handle AnyEvent correctly, implementation in BaseState was always run - Changing from ActiveState to ReadyState was bugged, previously only one of event SubprocessStopped or UdevNotification caused state change when it is required to wait for both - Introduced longer timer when waiting for ReadyState during Eject and ActiveState during Inject, because ndbkit can timeout during Eject and it is required to complete before next inject can success. - Added event notification when process is terminated - Added resourcess classes to handle deletion and notifications Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Signed-off-by: Karol Wachowski <karol.wachowski@intel.com> Change-Id: Ie914e650c2f15bd73cdc87582ea77a94997a3472 Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
2020-07-06VolatileFile security fixKrzysztof Grobelny1-18/+23
- Flushing file content before deleting it TESTED: Tested manually, no regression detected. Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Change-Id: Id48ebb6edbb2c0f0fbf930c2be9a63dd1034b7cc
2020-07-01Use timeout value from virtual-media.json fileKarol Wachowski2-2/+4
timeout value was always set to default instead of using configuration file. Tested: verified that timeout value set in /etc/virtual-media.json is actually used by service Signed-off-by: Karol Wachowski <karol.wachowski@intel.com> Change-Id: I6865f25c91d95eb273792798f6159838cfd013c5 Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
2020-06-30Fix stopping usbgadgetKarol Wachowski1-1/+2
Changed recursive removal (std::filesystem::remove_all) of all files in /sys/kernel/config/usb_gadget/ to rmdir operation (std::filesystem::remove). configfs does not allow recursive file removal and returns operation not permitted on such operations. It is required to execute rmmdir. Tested: verified that VirtualMedia drives can be restarted properly (stopped and started again) Change-Id: Ib0c66723b451e29f28c9c90029365385a41dc558 Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
2020-06-26Fix for defect `Misleading VM endpoints names`Zbigniew Kurzynski1-4/+4
Changing endpoint names to Slot_<X> convention. Tested: Tested manually, new endpoint names are available on dbus,redfish and finally on WebUI. Change-Id: I90c9dc9fab8314f498d7635d0c010dffdcdc24c9 Signed-off-by: Zbigniew Kurzynski <zbigniew.kurzynski@intel.com>
2020-05-06Bring back legacy endpoints in Virtual MediaAmbrozewicz, Adrian1-1/+17
This change brings back Legacy USB devices in VirtualMedia. It should be accepted after : https://git-amr-2.devtools.intel.com/gerrit/246113 Enable MTLS and VirtualMedia back Tested: - Both changes combined allows to mount devices in legacy mode Change-Id: I6ceb7a1c37f49dbc8ea7a5313bb264cf99051048 Signed-off-by: Ambrozewicz, Adrian <adrian.ambrozewicz@intel.com>
2020-04-03Make 'Legacy mode' (mounting through HTTPS or SMB) configurable at compile time.Adrian Ambrożewicz4-17/+17
This change modifies the default configuration and removes ability to configure endpoints in such mode. Tests performed: Tested on WilsonCity for regression. Proxy mode works. Manual configuration injection (modifying virtual-media.json) didn't enable Legacy endpoints - they are ignored. Change-Id: Idb63f1cf0f391dc428d6ad3d8e3684017d509369 Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com>
2020-02-28Fix for 'Mounting image using legacy mode with invalid credentialsAgata Olender1-2/+8
restart VM service'. Due to unsuccessful mounting of image, mount point changes state to ReadyState and perform reset on target object. Target is no longer available so fix assumes adding verification against null value before performing other reset on target fields. Tested manually for scenarios with valid and invalid passwords. Change-Id: I6c9d5f680f76af3c2ba609a7889552345451cf28 Signed-off-by: Agata Olender <agata.olender@intel.com>
2020-02-20Add handling of exit code property.Agata Olender1-6/+11
Property returns exit code value from nbd-client process for proxy mode and from nbdkit process for legacy mode. The initial value for this property is -1 and will be returned before starting the process and in the process execution time. Tested manually for proxy and legacy mode: - initial value before process first run - initial value in process execution time - 0 value for successful exit - specific value for forced process termination Change-Id: I4cefa423bade522fc2fac0cab620cbba0b66cce2 Signed-off-by: Agata Olender <agata.olender@intel.com>
2020-02-06Authentication support for Legacy modeAgata Olender3-13/+336
This change introduces new 'Mount' API argument - UNIX_FD for named pipe. This named pipe is utilized to securely send secret data over D-Bus. Currently data consists of null-terminated char buffers with username and password. Data on receiving side is encapsulated into classes whose role is to: - keep secret as short-lived as possible - erase secret from memory when it's not needed - pass secrets (and format them) to another secure container with above capabilities New classes: - Credentials: is a class encapsulating login and password. It zeroes them at destruction. - CredentialProvider: contains Credentials, specifies SecureBuffer, allows to store credentials in SecureBuffer - SecureBuffer: char vector which zeroes itself at destruction, used to provision secret data - VolatileFile: class creating temporary file with 'owner-only' permissions in /tmp; at destruction overwrites it's contents with '*' and removes it New behavior: - when UNIX_FD is provided over D-Bus it's treated as open unix pipe. Data is read from this pipe and stored securely into CredentialsProvider - credentials are stored in applications inside CredentialsProvider object, encapsulated by unique_ptr for as long as it's needed - strings containing secrets are zeroed immediately after use - VolatileFile is used to securely pass credentials to nbdkit curl plugin instead of command line parameters. Tested: Manual and automated tests on WilsonCity platform: - positive and negative tests for authentication on both CIFS and HTTPS resources - error injection (ill-formed data transfered over pipe, pipe broken etc.) Change-Id: I608ae0380b8ad57110bc0939f71eb48604e7dc99 Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com> Signed-off-by: Agata Olender <agata.olender@intel.com>
2020-02-06Detailed error handlingAgata Olender1-18/+50
Previously implemented error handling for Mount checks only if mounting was successful and returns boolean with the result. Following change introduces optional error to existing ReadyState (a.k.a. "idle state"). If state machine enters ReadyState with error it is stored into ReadyState field with std::errc and std::string message. In the case of mount failure with such error information stored, Mount returns graceful D-Bus error reply with specific error code. Tested: Manual and automated tests on WilsonCity platform: - negative tests for invalid network share, unauthorized share access, error injection (renaming expected unix socket names etc) Change-Id: I22cf9b17e9e6342aad0ae68766853734fac79b8e Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com> Signed-off-by: Agata Olender <agata.olender@intel.com>
2020-02-06Integration with NBDKit for Legacy modeAgata Olender5-30/+269
This change introduces integration of virtual-media application with NBDKit. NBDKit is used here to connect to externally provided image on web and expose NBD device internally in BMC for NBD subsystem (already implemented in Proxy mode) to use. 'Mount' D-Bus call accepts 's imgUrl' and 'b rw'. Based on 's imgUrl' prefix (https:// or smb://) proper mount type is attempted. 'b rw' determines Read-Only mode for both USB Gadget and NBD stack. When 'Mount' is called, virtual-media parses arguments, determines mounting options and attempts to mount external share. For SMB protocol native CIFS Linux module is used: 1) mount(8) call is used to mound provided CIFS share 2) NBDKit loads file on mounted filesystem and exposes NBD Server on internal unix socket 3) Pre-existing code takes care of mouting gadget automatically (connecting socket to /dev/nbdX and then /dev/nbdX to USB Gadget) For HTTPS protocol provisioning is performed by NBDKit: 1) NBDKit connects to provided resource and exposes NBD Server on internal unix socket 2) Pre-existing code takes care of mouting gadget automatically (connecting socket to /dev/nbdX and then /dev/nbdX to USB Gadget) Tested: Manual and automated tests on WilsonCity platform: - mounting and unmounting images over CIFS and HTTPS (single, multiple at the same time etc) - positive and negative tests for D-Bus calls - ensuring proper information is exposed on D-Bus Change-Id: Ia2b6e8c13603521063f5c94cdfdb06f2e872e9e7 Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com> Signed-off-by: Agata Olender <agata.olender@intel.com>
2020-01-29Gadget inactivity timeoutAgata Olender4-0/+94
MountPoints being inactive for time defined by InactivityTimeout will be unmounted. Inacitivity is measured based on USB gadget R/W statitics. InactivityTimeout must be set in json configuration and is common for all MountPoints. Remaining time to unmount inactive media is exposed per MountPoint on dbus using RemainingInactivityTimeout property. Change-Id: Ieb80e67dae6c3b4cb0482d801b5b4208884b0809 Signed-off-by: Agata Olender <agata.olender@intel.com>