Skip to content

Commit

Permalink
Prevent config.h from being clobbered
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Mar 7, 2013
1 parent 8057a19 commit 28bba8c
Show file tree
Hide file tree
Showing 27 changed files with 165 additions and 277 deletions.
7 changes: 3 additions & 4 deletions corepkgs/fetchurl.nix
@@ -1,17 +1,17 @@
with import <nix/config.nix>;

{system ? builtins.currentSystem, url, outputHash ? "", outputHashAlgo ? "", md5 ? "", sha1 ? "", sha256 ? "", executable ? false}:
{system ? builtins.currentSystem, url, outputHash ? "", outputHashAlgo ? "", md5 ? "", sha1 ? "", sha256 ? ""}:

assert (outputHash != "" && outputHashAlgo != "")
|| md5 != "" || sha1 != "" || sha256 != "";

let

builder = builtins.toFile "fetchurl.sh"
(''
''
echo "downloading $url into $out"
${curl} --fail --location --max-redirs 20 --insecure "$url" > "$out"
'' + (if executable then "${coreutils}/chmod +x $out" else ""));
'';

in

Expand All @@ -25,7 +25,6 @@ derivation {
if sha256 != "" then "sha256" else if sha1 != "" then "sha1" else "md5";
outputHash = if outputHash != "" then outputHash else
if sha256 != "" then sha256 else if sha1 != "" then sha1 else md5;
outputHashMode = if executable then "recursive" else "flat";

inherit system url;

Expand Down
33 changes: 33 additions & 0 deletions doc/dev/release-procedures.txt
@@ -0,0 +1,33 @@
To produce a `stable' release from the trunk:

-1. Update the release notes; make sure that the release date is
correct.

0. Make sure that the trunk builds in the release supervisor.

1. Branch the trunk, e.g., `svn cp .../trunk
.../branches/0.5-release'.

2. Switch to the branch, e.g., `svn switch .../branches/0.5-release'.

3. In `configure.ac', change `STABLE=0' into `STABLE=1' and commit.

4. In the release supervisor, add a one-time job to build
`.../branches/0.5-release'.

5. Make sure that the release succeeds.

6. Move the branch to a tag, e.g., `svn mv .../branches/0.5-release
.../tags/0.5'.

Note that the branch should not be used for maintenance; it should
be deleted after the release has been created. A maintenance
branch (e.g., `.../branches/0.5') should be created from the
original revision of the trunk (since maintenance releases should
also be tested first; hence, we cannot have `STABLE=1'). The same
procedure can then be followed to produce maintenance releases;
just substitute `.../branches/VERSION' for the trunk.

7. Switch back to the trunk.

8. Bump the version number in `configure.ac' (in AC_INIT).
12 changes: 0 additions & 12 deletions doc/manual/builtins.xml
Expand Up @@ -302,18 +302,6 @@ stdenv.mkDerivation {
</varlistentry>


<varlistentry><term><function>builtins.hashString</function>
<replaceable>type</replaceable> <replaceable>s</replaceable></term>

<listitem><para>Return a base-16 representation of the
cryptographic hash of string <replaceable>s</replaceable>. The
hash algorithm specified by <replaceable>type</replaceable> must
be one of <literal>"md5"</literal>, <literal>"sha1"</literal> or
<literal>"sha256"</literal>.</para></listitem>

</varlistentry>


<varlistentry><term><function>builtins.head</function>
<replaceable>list</replaceable></term>

Expand Down
9 changes: 4 additions & 5 deletions doc/manual/opt-common.xml
Expand Up @@ -343,11 +343,10 @@

<varlistentry><term><option>-I</option> <replaceable>path</replaceable></term>

<listitem><para>Add a path to the Nix expression search path. This
option may be given multiple times. See the <envar>NIX_PATH</envar>
environment variable for information on the semantics of the Nix
search path. Paths added through <option>-I</option> take
precedence over <envar>NIX_PATH</envar>.</para></listitem>
<listitem><para>Add a path to the Nix expression search path. See
the <envar>NIX_PATH</envar> environment variable for details. Paths
added through <option>-I</option> take precedence over
<envar>NIX_PATH</envar>.</para></listitem>

</varlistentry>

Expand Down
57 changes: 0 additions & 57 deletions doc/manual/release-notes.xml
Expand Up @@ -6,63 +6,6 @@



<!--==================================================================-->

<section xml:id="ssec-relnotes-1.5.1"><title>Release 1.5.1 (February 28, 2013)</title>

<para>The bug fix to the bug fix had a bug itself, of course. But
this time it will work for sure!</para>

</section>


<!--==================================================================-->

<section xml:id="ssec-relnotes-1.5"><title>Release 1.5 (February 27, 2013)</title>

<para>This is a brown paper bag release to fix a regression introduced
by the hard link security fix in 1.4.</para>

</section>


<!--==================================================================-->

<section xml:id="ssec-relnotes-1.4"><title>Release 1.4 (February 26, 2013)</title>

<para>This release fixes a security bug in multi-user operation. It
was possible for derivations to cause the mode of files outside of the
Nix store to be changed to 444 (read-only but world-readable) by
creating hard links to those files (<link
xlink:href="https://github.com/NixOS/nix/commit/5526a282b5b44e9296e61e07d7d2626a79141ac4">details</link>).</para>

<para>There are also the following improvements:</para>

<itemizedlist>

<listitem><para>New built-in function:
<function>builtins.hashString</function>.</para></listitem>

<listitem><para>Build logs are now stored in
<filename>/nix/var/log/nix/drvs/<replaceable>XX</replaceable>/</filename>,
where <replaceable>XX</replaceable> is the first two characters of
the derivation. This is useful on machines that keep a lot of build
logs (such as Hydra servers).</para></listitem>

<listitem><para>The function <function>corepkgs/fetchurl</function>
can now make the downloaded file executable. This will allow
getting rid of all bootstrap binaries in the Nixpkgs source
tree.</para></listitem>

<listitem><para>Language change: The expression <literal>"${./path}
..."</literal> now evaluates to a string instead of a
path.</para></listitem>

</itemizedlist>

</section>


<!--==================================================================-->

<section xml:id="ssec-relnotes-1.3"><title>Release 1.3 (January 4, 2013)</title>
Expand Down
21 changes: 9 additions & 12 deletions perl/lib/Nix/Store.xs
Expand Up @@ -15,7 +15,7 @@
using namespace nix;


void doInit()
void doInit()
{
if (!store) {
try {
Expand Down Expand Up @@ -237,35 +237,32 @@ SV * derivationFromPath(char * drvPath)
doInit();
Derivation drv = derivationFromPath(*store, drvPath);
hash = newHV();

HV * outputs = newHV();
for (DerivationOutputs::iterator i = drv.outputs.begin(); i != drv.outputs.end(); ++i)
hv_store(outputs, i->first.c_str(), i->first.size(), newSVpv(i->second.path.c_str(), 0), 0);
hv_stores(hash, "outputs", newRV((SV *) outputs));


/* TODO: handle drv.outputs */

AV * inputDrvs = newAV();
for (DerivationInputs::iterator i = drv.inputDrvs.begin(); i != drv.inputDrvs.end(); ++i)
av_push(inputDrvs, newSVpv(i->first.c_str(), 0)); // !!! ignores i->second
hv_stores(hash, "inputDrvs", newRV((SV *) inputDrvs));

AV * inputSrcs = newAV();
for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i)
av_push(inputSrcs, newSVpv(i->c_str(), 0));
hv_stores(hash, "inputSrcs", newRV((SV *) inputSrcs));

hv_stores(hash, "platform", newSVpv(drv.platform.c_str(), 0));
hv_stores(hash, "builder", newSVpv(drv.builder.c_str(), 0));

AV * args = newAV();
for (Strings::iterator i = drv.args.begin(); i != drv.args.end(); ++i)
av_push(args, newSVpv(i->c_str(), 0));
hv_stores(hash, "args", newRV((SV *) args));

HV * env = newHV();
for (StringPairs::iterator i = drv.env.begin(); i != drv.env.end(); ++i)
hv_store(env, i->first.c_str(), i->first.size(), newSVpv(i->second.c_str(), 0), 0);
hv_stores(hash, "env", newRV((SV *) env));

RETVAL = newRV_noinc((SV *)hash);
} catch (Error & e) {
croak(e.what());
Expand Down
5 changes: 2 additions & 3 deletions scripts/build-remote.pl.in
Expand Up @@ -258,9 +258,8 @@ close UPLOADLOCK;

# Perform the build.
my $buildFlags =
"--max-silent-time $maxSilentTime --option build-timeout $buildTimeout"
. " --fallback --add-root $rootsDir/\$PPID.out --quiet"
. " --option build-keep-log false";
"--max-silent-time $maxSilentTime --option build-timeout $buildTimeout "
. "--fallback --add-root $rootsDir/\$PPID.out --option verbosity 0";

# We let the remote side kill its process group when the connection is
# closed unexpectedly. This is necessary to ensure that no processes
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/eval.cc
Expand Up @@ -966,7 +966,7 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
since paths are copied when they are used in a derivation),
and none of the strings are allowed to have contexts. */
if (first) {
isPath = !forceString && vStr.type == tPath;
isPath = vStr.type == tPath;
first = false;
}

Expand Down
4 changes: 1 addition & 3 deletions src/libexpr/nixexpr.hh
Expand Up @@ -277,10 +277,8 @@ MakeBinOp(OpConcatLists, "++")

struct ExprConcatStrings : Expr
{
bool forceString;
vector<Expr *> * es;
ExprConcatStrings(bool forceString, vector<Expr *> * es)
: forceString(forceString), es(es) { };
ExprConcatStrings(vector<Expr *> * es) : es(es) { };
COMMON_METHODS
};

Expand Down
6 changes: 3 additions & 3 deletions src/libexpr/parser.y
Expand Up @@ -203,7 +203,7 @@ static Expr * stripIndentation(SymbolTable & symbols, vector<Expr *> & es)
es2->push_back(new ExprString(symbols.create(s2)));
}

return es2->size() == 1 ? (*es2)[0] : new ExprConcatStrings(true, es2);
return es2->size() == 1 ? (*es2)[0] : new ExprConcatStrings(es2);
}


Expand Down Expand Up @@ -318,7 +318,7 @@ expr_op
{ vector<Expr *> * l = new vector<Expr *>;
l->push_back($1);
l->push_back($3);
$$ = new ExprConcatStrings(false, l);
$$ = new ExprConcatStrings(l);
}
| expr_op CONCAT expr_op { $$ = new ExprOpConcatLists($1, $3); }
| expr_app
Expand Down Expand Up @@ -349,7 +349,7 @@ expr_simple
/* For efficiency, and to simplify parse trees a bit. */
if ($2->empty()) $$ = new ExprString(data->symbols.create(""));
else if ($2->size() == 1) $$ = $2->front();
else $$ = new ExprConcatStrings(true, $2);
else $$ = new ExprConcatStrings($2);
}
| IND_STRING_OPEN ind_string_parts IND_STRING_CLOSE {
$$ = stripIndentation(data->symbols, *$2);
Expand Down
16 changes: 0 additions & 16 deletions src/libexpr/primops.cc
Expand Up @@ -1107,21 +1107,6 @@ static void prim_unsafeDiscardOutputDependency(EvalState & state, Value * * args
}


/* Return the cryptographic hash of a string in base-16. */
static void prim_hashString(EvalState & state, Value * * args, Value & v)
{
string type = state.forceStringNoCtx(*args[0]);
HashType ht = parseHashType(type);
if (ht == htUnknown)
throw Error(format("unknown hash type `%1%'") % type);

PathSet context; // discarded
string s = state.forceString(*args[1], context);

mkString(v, printHash(hashString(ht, s)), context);
};


/*************************************************************
* Versions
*************************************************************/
Expand Down Expand Up @@ -1249,7 +1234,6 @@ void EvalState::createBaseEnv()
addPrimOp("__stringLength", 1, prim_stringLength);
addPrimOp("__unsafeDiscardStringContext", 1, prim_unsafeDiscardStringContext);
addPrimOp("__unsafeDiscardOutputDependency", 1, prim_unsafeDiscardOutputDependency);
addPrimOp("__hashString", 2, prim_hashString);

// Versions
addPrimOp("__parseDrvName", 1, prim_parseDrvName);
Expand Down
7 changes: 5 additions & 2 deletions src/libmain/shared.cc
Expand Up @@ -168,10 +168,11 @@ static void initAndRun(int argc, char * * argv)
remaining.clear();

/* Process default options. */
int verbosityDelta = lvlInfo;
for (Strings::iterator i = args.begin(); i != args.end(); ++i) {
string arg = *i;
if (arg == "--verbose" || arg == "-v") verbosity = (Verbosity) (verbosity + 1);
else if (arg == "--quiet") verbosity = verbosity > lvlError ? (Verbosity) (verbosity - 1) : lvlError;
if (arg == "--verbose" || arg == "-v") verbosityDelta++;
else if (arg == "--quiet") verbosityDelta--;
else if (arg == "--log-type") {
string s = getArg(arg, i, args.end());
setLogType(s);
Expand Down Expand Up @@ -218,6 +219,8 @@ static void initAndRun(int argc, char * * argv)
else remaining.push_back(arg);
}

verbosity = (Verbosity) (verbosityDelta < 0 ? 0 : verbosityDelta);

settings.update();

run(remaining);
Expand Down
18 changes: 5 additions & 13 deletions src/libstore/build.cc
Expand Up @@ -43,12 +43,6 @@
#include <sched.h>
#endif

/* In GNU libc 2.11, <sys/mount.h> does not define `MS_PRIVATE', but
<linux/fs.h> does. */
#if !defined MS_PRIVATE && defined HAVE_LINUX_FS_H
#include <linux/fs.h>
#endif

#define CHROOT_ENABLED HAVE_CHROOT && HAVE_UNSHARE && HAVE_SYS_MOUNT_H && defined(MS_BIND) && defined(MS_PRIVATE) && defined(CLONE_NEWNS)

#if CHROOT_ENABLED
Expand Down Expand Up @@ -2287,7 +2281,7 @@ void DerivationGoal::computeClosure()
}

/* Get rid of all weird permissions. */
canonicalisePathMetaData(path, buildUser.enabled() ? buildUser.getUID() : -1);
canonicalisePathMetaData(path);

/* For this output path, find the references to other paths
contained in it. Compute the SHA-256 NAR hash at the same
Expand Down Expand Up @@ -2349,15 +2343,13 @@ Path DerivationGoal::openLogFile()
{
if (!settings.keepLog) return "";

string baseName = baseNameOf(drvPath);

/* Create a log file. */
Path dir = (format("%1%/%2%/%3%/") % settings.nixLogDir % drvsLogDir % string(baseName, 0, 2)).str();
Path dir = (format("%1%/%2%") % settings.nixLogDir % drvsLogDir).str();
createDirs(dir);

if (settings.compressLog) {

Path logFileName = (format("%1%/%2%.bz2") % dir % string(baseName, 2)).str();
Path logFileName = (format("%1%/%2%.bz2") % dir % baseNameOf(drvPath)).str();
AutoCloseFD fd = open(logFileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666);
if (fd == -1) throw SysError(format("creating log file `%1%'") % logFileName);
closeOnExec(fd);
Expand All @@ -2372,7 +2364,7 @@ Path DerivationGoal::openLogFile()
return logFileName;

} else {
Path logFileName = (format("%1%/%2%") % dir % string(baseName, 2)).str();
Path logFileName = (format("%1%/%2%") % dir % baseNameOf(drvPath)).str();
fdLogFile = open(logFileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666);
if (fdLogFile == -1) throw SysError(format("creating log file `%1%'") % logFileName);
closeOnExec(fdLogFile);
Expand Down Expand Up @@ -2839,7 +2831,7 @@ void SubstitutionGoal::finished()
return;
}

canonicalisePathMetaData(destPath, -1);
canonicalisePathMetaData(destPath);

worker.store.optimisePath(destPath); // FIXME: combine with hashPath()

Expand Down
5 changes: 1 addition & 4 deletions src/libstore/gc.cc
Expand Up @@ -659,10 +659,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
increase, since we hold locks on everything. So everything
that is not reachable from `roots'. */

if (state.shouldDelete) {
if (pathExists(state.trashDir)) deleteGarbage(state, state.trashDir);
createDirs(state.trashDir);
}
if (state.shouldDelete) createDirs(state.trashDir);

/* Now either delete all garbage paths, or just the specified
paths (for gcDeleteSpecific). */
Expand Down

1 comment on commit 28bba8c

@shlevy
Copy link
Member

@shlevy shlevy commented on 28bba8c Mar 8, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit seems to have rolled back a lot of changes that are unrelated to config.h (including moving the version number back to 1.3), are you sure this is what you wanted?

Please sign in to comment.