summaryrefslogtreecommitdiff
path: root/hscript
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-18 23:24:48 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-19 01:42:55 -0500
commit2374778a55f9380ee5b821eb9563e20aad1bc3de (patch)
tree17ed4eda5d83f48d15c11cb8979be5f270440417 /hscript
parentda01034909eba11be184cedb408f34732a33c4cd (diff)
downloadhorizon-2374778a55f9380ee5b821eb9563e20aad1bc3de.tar.gz
horizon-2374778a55f9380ee5b821eb9563e20aad1bc3de.tar.bz2
horizon-2374778a55f9380ee5b821eb9563e20aad1bc3de.tar.xz
horizon-2374778a55f9380ee5b821eb9563e20aad1bc3de.zip
hscript: More LCOV fixes
Diffstat (limited to 'hscript')
-rw-r--r--hscript/network.cc63
-rw-r--r--hscript/user.cc4
2 files changed, 36 insertions, 31 deletions
diff --git a/hscript/network.cc b/hscript/network.cc
index 1197944..0921aaf 100644
--- a/hscript/network.cc
+++ b/hscript/network.cc
@@ -37,6 +37,7 @@ bool Network::execute(ScriptOptions) const {
return true;
}
+
Key *NetAddress::parseFromData(const std::string &data, int lineno, int *errors,
int *warnings) {
long elements = std::count(data.cbegin(), data.cend(), ' ') + 1;
@@ -226,6 +227,7 @@ bool NetAddress::execute(ScriptOptions) const {
return false;
}
+
Key *NetSSID::parseFromData(const std::string &data, int lineno, int *errors,
int *warnings) {
std::string iface, ssid, secstr, passphrase;
@@ -311,40 +313,43 @@ Key *NetSSID::parseFromData(const std::string &data, int lineno, int *errors,
}
bool NetSSID::validate(ScriptOptions options) const {
- /* Runner.Validate.network.netssid.Interface */
- if(options.test(InstallEnvironment)) {
- struct iwreq request;
- int my_sock = ::socket(AF_INET, SOCK_STREAM, 0);
- if(my_sock == -1) {
+ /* REQ: Runner.Validate.network.netssid.Interface */
+ if(!options.test(InstallEnvironment)) {
+ return true;
+ }
+
+ /* LCOV_EXCL_START */
+ struct iwreq request;
+ int my_sock = ::socket(AF_INET, SOCK_STREAM, 0);
+ if(my_sock == -1) {
+ output_error("installfile:" + std::to_string(this->lineno()),
+ "netssid: can't open socket", ::strerror(errno));
+ return false;
+ }
+ memset(&request, 0, sizeof(request));
+ memcpy(&request.ifr_ifrn.ifrn_name, this->_iface.c_str(),
+ this->_iface.size());
+ errno = 0;
+ if(ioctl(my_sock, SIOCGIWNAME, &request) == -1) {
+ switch(errno)
+ {
+ case EOPNOTSUPP:
+ output_warning("installfile:" + std::to_string(this->lineno()),
+ "netssid: specified interface is not wireless");
+ return true;
+ case ENODEV:
+ output_warning("installfile:" + std::to_string(this->lineno()),
+ "netssid: specified interface does not exist");
+ return true;
+ default:
output_error("installfile:" + std::to_string(this->lineno()),
- "netssid: can't open socket", ::strerror(errno));
+ "netssid: error communicating with wireless device");
return false;
}
- memset(&request, 0, sizeof(request));
- memcpy(&request.ifr_ifrn.ifrn_name, this->_iface.c_str(),
- this->_iface.size());
- errno = 0;
- if(ioctl(my_sock, SIOCGIWNAME, &request) == -1) {
- switch(errno)
- {
- case EOPNOTSUPP:
- output_warning("installfile:" + std::to_string(this->lineno()),
- "netssid: interface specified is not wireless");
- return true;
- case ENODEV:
- output_warning("installfile:" + std::to_string(this->lineno()),
- "netssid: specified interface does not exist");
- return true;
- default:
- output_error("installfile:" + std::to_string(this->lineno()),
- "netssid: error communicating with wireless device");
- return false;
- }
- }
- ::close(my_sock);
- return true;
}
+ ::close(my_sock);
return true;
+ /* LCOV_EXCL_STOP */
}
bool NetSSID::execute(ScriptOptions) const {
diff --git a/hscript/user.cc b/hscript/user.cc
index 8382f1c..9bc6864 100644
--- a/hscript/user.cc
+++ b/hscript/user.cc
@@ -132,6 +132,8 @@ bool RootPassphrase::execute(ScriptOptions options) const {
return true;
}
+ /* LCOV_EXCL_START */
+ /* This was tested on gwyn during development. */
std::ifstream old_shadow("/target/etc/shadow");
if(!old_shadow) {
output_error("installfile:" + std::to_string(this->lineno()),
@@ -139,8 +141,6 @@ bool RootPassphrase::execute(ScriptOptions options) const {
return false;
}
- /* LCOV_EXCL_START */
- /* This was tested on gwyn during development. */
std::stringstream shadow_stream;
char shadow_line[200];
/* Discard root. */