Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into drop_unused_system_…
Browse files Browse the repository at this point in the history
…parts

Conflicts:
	agent-system/src/SystemAgent.cc
  • Loading branch information
jreidinger committed Nov 8, 2013
2 parents 578f921 + 6a9253b commit 5110cd0
Show file tree
Hide file tree
Showing 117 changed files with 1,349 additions and 1,791 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ config.log
config.status
config.sub
configure
configure.in
configure.ac
depcomp
install-sh
Expand All @@ -42,3 +43,4 @@ tmp.*
*/testsuite/*.sum
*/testsuite/site.exp
*.in.test
/config.h.in~
87 changes: 87 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
YaST Contribution Guidelines
============================

YaST is an open source project and as such it welcomes all kinds of
contributions. If you decide to contribute, please follow these guidelines to
ensure the process is effective and pleasant both for you and YaST maintainers.

There are two main forms of contribution: reporting bugs and performing code
changes.

Bug Reports
-----------

If you find a problem, please report it either using
[Bugzilla](https://bugzilla.novell.com/enter_bug.cgi?format=guided&product=openSUSE+Factory&component=YaST2)
or [GitHub issues](../../issues). (For Bugzilla, use the [simplified
registration](https://secure-www.novell.com/selfreg/jsp/createSimpleAccount.jsp)
if you don't have an account yet.)

If you find a problem, please report it either using
[Bugzilla](https://bugzilla.novell.com/) or GitHub issues. We can't guarantee
that every bug will be fixed, but we'll try.

When creating a bug report, please follow our [bug reporting
guidelines](http://en.opensuse.org/openSUSE:Report_a_YaST_bug).

Code Changes
------------

We welcome all kinds of code contributions, from simple bug fixes to significant
refactorings and implementation of new features. However, before making any
non-trivial contribution, get in touch with us first — this can prevent wasted
effort on both sides. Also, have a look at our [development
documentation](http://en.opensuse.org/openSUSE:YaST_development).

To send us your code change, use GitHub pull requests. The workflow is as
follows:

1. Fork the project.

2. Create a topic branch based on `master`.

3. Implement your change, including tests (if possible). Make sure you adhere
to the [Ruby style
guide](https://github.com/SUSE/style-guides/blob/master/Ruby.md).

4. Make sure your change didn't break anything by building the RPM package
(`rake osc:build`). The build process includes running the full testsuite.

5. Publish the branch and create a pull request.

6. YaST developers will review your change and possibly point out issues.
Adapt the code under their guidance until they are all resolved.

7. Finally, the pull request will get merged or rejected.

See also [GitHub's guide on
contributing](https://help.github.com/articles/fork-a-repo).

If you want to do multiple unrelated changes, use separate branches and pull
requests.

Do not change the `VERSION` and `*.changes` files as this could lead to
conflicts.

### Commits

Each commit in the pull request should do only one thing, which is clearly
described by its commit message. Especially avoid mixing formatting changes and
functional changes into one commit. When writing commit messages, adhere to
[widely used
conventions](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).

If your commit is related to a bug in Buzgilla or an issue on GitHub, make sure
you mention it in the commit message for cross-reference. Use format like
bnc#775814 or gh#yast/yast-foo#42. See also [GitHub
autolinking](https://help.github.com/articles/github-flavored-markdown#references)
and [openSUSE abbreviation
reference](http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines#Current_set_of_abbreviations).

Additional Information
----------------------

If you have any question, feel free to ask at the [development mailing
list](http://lists.opensuse.org/yast-devel/) or at the
[#yast](http://webchat.freenode.net/?channels=%23yast) IRC channel on freenode.
We'll do our best to provide a timely and accurate answer.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.3
3.1.4
150 changes: 91 additions & 59 deletions agent-any/src/AnyAgent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ YCPValue
AnyAgent::otherCommand (const YCPTerm & term)
{
const string sym = term->name ();

y2debug( "Received term in otherCommand: %s", term->toString().c_str() );

if (sym == "Description" && term->size () >= 4)
Expand Down Expand Up @@ -471,7 +471,7 @@ AnyAgent::Write (const YCPPath & path, const YCPValue & value,

y2debug (" to %s", fname);

std::ofstream dummy_file (fname);
std::ofstream dummy_file (targetPath(fname));
if (!dummy_file)
{
ycp2error ("Can't open path %s", sfname.c_str ());
Expand Down Expand Up @@ -642,6 +642,62 @@ AnyAgent::evalArg (const YCPValue & arg)
}


static FILE* program_stream(const char *s, SCRAgent* agent)
{
y2debug ("readFile, run (%s)", s);

int read_pipes[2];

int res = pipe(&read_pipes[0]);
if (res == -1)
{
y2error("Cannot open pipe: %s", strerror(errno));
return NULL;
}

switch (fork())
{
case -1:
y2error("fork failed: %s", strerror(errno));
return NULL;
case 0: // child
close(STDIN_FILENO);
close(STDERR_FILENO);
close(read_pipes[0]);
dup2(read_pipes[1], STDOUT_FILENO);
close(read_pipes[1]);

if (strcmp(agent->root(), "/") != 0)
{
int res = chroot(agent->root());
if (res == -1)
_exit(1);

// Do not allow touch outside of chroot especially `cd ~` can
// cause errors
chdir("/");
}
// lets ignore if it fails, we even cannot log here
setenv ("LC_ALL", "C", 1);

execlp("sh", "sh", "-c", s, NULL);
// if exec fail exit with 1
_exit(1);
default: // parent
close(read_pipes[1]);
return fdopen(read_pipes[0], "r");
}
}

static inline FILE* file_stream(const char *s, SCRAgent* agent)
{
y2debug ("readFile, read (%s)", s);

// open file
return fopen (agent->targetPath(s).c_str(), "r");
}


/**
* readFile
*
Expand Down Expand Up @@ -669,27 +725,10 @@ AnyAgent::readFile (const YCPValue & arg)

if (mType == MTYPE_PROG)
{
const char *s = ss.c_str ();
y2debug ("readFile, run (%s)", s);

// always invalidate cache
buf.st_mtime = 0;

const char *original_locale = getenv ("LC_ALL");
if (setenv ("LC_ALL", "C", 1) < 0)
y2error ("Cannot reset locales;");

fp = popen (s, "r");

if (original_locale)
{
if (setenv ("LC_ALL", original_locale, 1) < 0)
y2error ("Cannot revert locales;");
}
else
{
unsetenv ("LC_ALL");
}
fp = program_stream(ss.c_str(), this);

if (fp == 0)
{
Expand All @@ -699,41 +738,37 @@ AnyAgent::readFile (const YCPValue & arg)
}
else
{
const char *s = ss.c_str ();

y2debug ("readFile, read (%s)", s);

if (stat (s, &buf) != 0)
{
mtime = 0; // error case: reset mtime
if (errno == ENOENT)
{
ycp2error ("File not found %s", s);
return YCPList ();
}

ycp2error ("Can't stat '%s' :%d", s, errno);
return YCPNull ();
}

if (buf.st_mtime == mtime)
return alldata;

// open file

fp = fopen (s, "r");

if (fp == 0)
{
if (errno == EACCES)
{
ycp2error ("Cant access %s", s);
return YCPList ();
}

ycp2error ( "Error opening '%s': %d", s, errno);
return YCPNull ();
}
const char *s = ss.c_str();
// Check modify time if we can use cache
if (stat (s, &buf) != 0)
{
mtime = 0; // error case: reset mtime
if (errno == ENOENT)
{
ycp2error ("File not found %s", s);
return YCPList ();
}

ycp2error ("Can't stat '%s' :%d", s, errno);
return YCPNull ();
}

if (buf.st_mtime == mtime)
return alldata;

fp = file_stream(s, this);

if (fp == 0)
{
if (errno == EACCES)
{
ycp2error ("Cant access %s", s);
return YCPList ();
}

ycp2error ( "Error opening '%s': %d", s, errno);
return YCPNull ();
}
}

// read complete file to alldata as YCPListRep (YCPStringRep)
Expand All @@ -746,10 +781,7 @@ AnyAgent::readFile (const YCPValue & arg)
data->add (YCPString (line));
}

if (mType == MTYPE_PROG)
pclose (fp);
else
fclose (fp);
fclose (fp);

mtime = buf.st_mtime;
alldata = data;
Expand Down
2 changes: 1 addition & 1 deletion agent-any/src/AnyAgentComplex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ AnyAgent::unparseTuple (const YCPList & syntax, const YCPValue & value)
if (element->valuetype () == YT_TERM)
{
YCPTerm term = element->asTerm ();
if (!(term.isNull ()) &&
if (!(term.isNull ()) &&
((term->name () == "Skip") ||
(term->name () == "Fillup")))
continue;
Expand Down
Empty file.
Empty file.
1 change: 1 addition & 0 deletions agent-any/testsuite/tests/run_df.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
("OK, non-empty df")
27 changes: 27 additions & 0 deletions agent-any/testsuite/tests/run_df.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.

`ag_anyagent(
`Description (
(`Run("/bin/df -P 2>/dev/null")), // real file name
"\n", // Comment
true, // read-only
(`List (
`Tuple (
`spec (`String("^\t ")),
`Separator ("\t "),
`whole (`String("^\t ")),
`Separator ("\t "),
`used (`String("^\t ")),
`Separator ("\t "),
`free (`String("^ \t")),
`Separator ("\t "),
`prz (`String("^ \t")),
`Separator ("\t "),
`name (`String("^ \t\n")),
`Optional(`Whitespace()),
`Optional(`dummy (`String("^ \t\n")))
),
"\n"
))
)
)
5 changes: 5 additions & 0 deletions agent-any/testsuite/tests/run_df.ycp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
list items = (list)SCR::Read(.);
string result = size(items) > 0 ? "OK, non-empty df": "WTF, empty df";
return result;
}
2 changes: 1 addition & 1 deletion agent-dummy/src/DummyAgent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ DummyAgent::Execute (const YCPPath& path, const YCPValue& value,
{
v = checkPath(path, defaultMap, deflt);
}

ycpdebug("%sExecute %s", DUMMY_LOG_STRING,
(path->toString() + " " + value->toString() +
(arg.isNull()?"":(" "+arg->toString())) +
Expand Down
Loading

0 comments on commit 5110cd0

Please sign in to comment.