-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed check_options to Nfs::Options::validate
- Loading branch information
Showing
12 changed files
with
115 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
|
||
module "Nfs::Options"; | ||
textdomain "nfs"; | ||
|
||
/** | ||
* Checks the nfs options for /etc/fstab: | ||
* nonempty, comma separated list of foo,nofoo,bar=baz (see nfs(5)) | ||
* @param options options | ||
* @return a translated string with error message, emtpy string if ok | ||
*/ | ||
global define string validate (string options) { | ||
// To translators: error popup | ||
if (size (options) == 0) return _("Empty option strings are not allowed."); | ||
if (options == "defaults") return ""; | ||
|
||
|
||
list<string> option_list = splitstring (options, ","); | ||
|
||
//the options must be easy to sync with mount.c and nfsmount.c | ||
|
||
// these can be negated by "no" | ||
list<string> non_value = ["bg", "fg", "soft", "hard", "intr", "posix", "cto", "ac", "acl", | ||
"lock", "tcp", "udp", "rdirplus", | ||
// these are common for all fs types | ||
"atime", "auto", "dev", "exec", "group", "owner", | ||
"suid", "user", "users"]; | ||
// these cannot be negated | ||
// they are not nfs specific BTW | ||
list non_value1 = ["defaults", "async", "sync", "dirsync", "ro", "rw", | ||
"remount", "bind", "rbind", "_netdev", ]; | ||
list with_value = ["rsize", "wsize", "timeo", "retrans", "acregmin", "acregmax", | ||
"acdirmin", "acdirmin", "acdirmax", "actimeo", "retry", "namlen", | ||
"port", "proto", "clientaddr", "mountport", "mounthost", | ||
"mountprog", "mountvers", "nfsprog", "nfsvers", "vers", | ||
"sec" ]; | ||
integer i = 0; | ||
string current_option = ""; | ||
|
||
// first fiter out non value options and its nooptions forms (see nfs(5)) | ||
option_list = filter (string e, option_list, ``(!contains (non_value, e))); | ||
non_value = maplist (string e, non_value, ``(sformat ("no%1", e))); | ||
option_list = filter (string e, option_list, ``(!contains (non_value, e))); | ||
option_list = filter (string e, option_list, ``(!contains (non_value1, e))); | ||
|
||
while (i < size (option_list)) | ||
{ | ||
string opt = option_list[i]:""; | ||
list<string> value = splitstring (opt, "="); | ||
string v0 = value[0]:""; | ||
string v1 = value[1]:""; | ||
// FIXME: this also triggers for "intr=bogus" | ||
// To translators: error popup | ||
if (!contains (with_value, v0)) return sformat (_("Unknown option: %1"), v0); | ||
// To translators: error popup | ||
if (size (value) != 2) return sformat (_("Invalid option: %1"), opt); | ||
// To translators: error popup | ||
if (v1 == "") return sformat (_("Empty value for option: %1"), v0); | ||
i = i + 1; | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
/*EOF*/ | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Dump Nfs::Options::validate | ||
Return Empty option strings are not allowed. | ||
Return | ||
Return | ||
Return | ||
Return | ||
Return Unknown option: bg | ||
Return Unknown option: unknownoption | ||
Return Unknown option: unknownassignment | ||
Return Empty value for option: rsize | ||
Return Unknown option: two |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
include "testsuite.ycp"; | ||
import "Nfs::Options"; | ||
|
||
DUMP ("Nfs::Options::validate"); | ||
TEST (``(Nfs::Options::validate ("")), [], nil); | ||
TEST (``(Nfs::Options::validate ("defaults")), [], nil); | ||
TEST (``(Nfs::Options::validate ("nolock,bg")), [], nil); | ||
TEST (``(Nfs::Options::validate ("nolock,nobg")), [], nil); | ||
TEST (``(Nfs::Options::validate ("nolock,rsize=8192")), [], nil); | ||
TEST (``(Nfs::Options::validate ("nolock, bg")), [], nil); | ||
TEST (``(Nfs::Options::validate ("nolock,unknownoption")), [], nil); | ||
TEST (``(Nfs::Options::validate ("nolock,unknownassignment=true")), [], nil); | ||
TEST (``(Nfs::Options::validate ("nolock,rsize=")), [], nil); | ||
TEST (``(Nfs::Options::validate ("nolock,two=equal=signs")), [], nil); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters