Commit graph

391 commits

Author SHA1 Message Date
Sitaram Chamarty 6863dca73a retain old file's permissions in wrap_print()
wrap_print() was written to create a new file and rename the old one to
avoid a partially written file being read by other processes.  This has
only been reported for the 'projects.list' file, but I just did it for
all files as a matter of course.

list of files currently written via this function:
gl-creater, gl-perms, description, git-daemon-export-ok, projects.list

However, some people want to do the following:

  - set REPO_UMASK tight (0077, default)
  - manually change the perms to something looser (typically g+rX) for
    specific repos
  - set core.sharedRepository to 0750 (git is documented to honor that
    config if available and to override umask)

Except that core.sharedRepository does not apply to files written by
gitolite and not git itself.  So they would open up their description
files and the next compile would close them again!

This patch prevents this from happening.  If the file already exists, it
maintains the same permissions after the rename.
2011-09-02 16:45:27 +05:30
Sitaram Chamarty e139be927a new 'subconf' feature to explicitly do delegation
(includes HOSTNAME substitution feature also...)
2011-08-30 20:50:34 +05:30
Sitaram Chamarty 0ec3d77761 delegation: allow includes in fragments, fixup doc
I could not think why we disallowed includes in subconfs, since an
include is the same as inserting all those lines inline anyway.
2011-08-30 11:42:03 +05:30
Sitaram Chamarty d01f6b1dbb config variables should not be restricted to double quoted strings
previously, these two would produce different results

    config aa.bb = 'true'   # config file line includes single quotes
    config aa.bb = "true"   # config file line does not include any quotes

Now the former will also behave like the latter.
2011-08-29 14:20:34 +05:30
Sitaram Chamarty 2eee4d627a Merge 'mirroring-revamp' into pu 2011-08-29 13:57:38 +05:30
Sitaram Chamarty 52cb3e1b8d gl-setup-authkeys had an obsolete usage message 2011-08-26 07:10:56 +05:30
Sitaram Chamarty e970327cc1 rc: get rid of GL_GITCONFIG_WILD
was only for efficiency even when it was relevant, and now it's just in
the way, making useless noises.
2011-08-17 21:53:06 +05:30
Sitaram Chamarty 056459aeda fix sequencing for repo config statements
Without this, complex mirroring scenarios will be unpredictable.  For
example (abbreviating "gitolite.mirror." to "gimo.") something as simple
as this will not give "foo" his different mirror setup

    repo @all
        config gimo.master = "frodo"
        config gimo.slaves = "sam"

    repo foo
        config gimo.master = "sam"
        config gimo.slaves = "frodo gollum"

    repo foo bar
        RW  =   u1

Even worse things happen when you have wild cards.

Now, however, they all come in the right sequence and the most recent
one takes effect (unlike ACL rules, where the first match wins, because
there you're trying to just find a match and get out, while here you're
just mindlessly applying config lines in the right order).
2011-08-17 21:03:14 +05:30
Sitaram Chamarty 4b9bf222e5 (mirroring) make bg push errors more visible/easier to grep 2011-08-16 14:28:01 +05:30
Sitaram Chamarty fabfcb5c19 default remote command should be 'info' if none given 2011-08-15 07:02:43 +05:30
Sitaram Chamarty ae20d5c6a7 log_it(): GL_USER may be undefined...
with gl-mirror-shell being a command you can just type on the server,
GL_USER may be undefined, so we now avoid those unsightly warnings
2011-08-15 07:02:43 +05:30
Sitaram Chamarty b11d44e036 (mirroring) make cron jobs easier to write
gl-mirror-shell will now take a list of slaves and/or keys, expanding
the keys in place.  See doc for even more improvements and conveniences.
2011-08-15 07:02:42 +05:30
Sitaram Chamarty aa7ff8ac27 (mirroring) some more error checking 2011-08-14 22:22:31 +05:30
Sitaram Chamarty a3ffc9d8fd (mirroring) reject non-local pushes if GL_HOSTNAME not set
We previously said all mirroring features are disabled if GL_HOSTNAME is
not set.

But what if, after mirroring has been setup, and master/slaves defined
for a repo, a slave admin fat-fingers the RC file and accidentally
comments out GL_HOSTNAME?  We might end up violating RULE NUMBER ONE!
2011-08-13 14:32:38 +05:30
Sitaram Chamarty 5143cc890f (new mirroring) enhance gl-tool
...it now does the mirroring peer key setup, unlike the kludgy manual way in the old setup
2011-08-12 22:51:44 +05:30
Sitaram Chamarty 68b45e1616 (new mirroring) bulk of the changes are here:
- post-receive now just calls mirror-push
  - mirror-push is a medium complex shell script (all that backgrounding
    etc., can't be done so easily in God's first language!)
  - mirror-shell is now a perl program that does a few different things
    (receive mirror-pushes, command line re-sync, re-sync requests from a
    slave, etc)
  - auth-command changes to reject/redirect non-native pushes
2011-08-12 22:51:44 +05:30
Sitaram Chamarty 15db108e45 (new mirroring) helpers, hostname, detect use of older RC variables, delete mirror-sync 2011-08-12 22:51:44 +05:30
Sitaram Chamarty b70cf05b43 (minor) allow a comma in regex pattern for wild repos
This was an oversight.  We already allow { and } anyway...
2011-08-12 21:45:23 +05:30
Sitaram Chamarty 0b68365860 fix accumulation of 'config' (git config) lines
If a repo matches multiple patterns, 'config' lines were being picked up
only from one of the 'repo' paras, instead of from all applicable ones.
2011-08-08 09:47:56 +05:30
Sitaram Chamarty 66f2065098 deal with a perl 5.14 deprecation on qw()
Apparently 5.14 deprecates using qw() as parentheses

(thanks to Benjamin Severs)
2011-08-04 22:01:13 +05:30
Sitaram Chamarty 49f5361799 (minor) don't ignore dirty-ness when generating version number 2011-07-29 14:12:56 +05:30
Sitaram Chamarty 6b65ffbab4 (minor) setperms and DOS users
Supporting git on DOS may be a fact of life, but it felt good to make
them use the "right" editor (hint: starts with v, ends with m, has three
letters), or at least something equivalent, to produce their setperms
input files.

I'd say "yes Fred I know.  However, Unix doesn't work like that, and
when talking to a big, important, OS like Unix from your little
single-user workstation, you do have to go the extra mile.  It's not
that different from going into a meeting with the CEO you know -- you
dress up a little for that meeting don't you?".  And Fred would nod, a
little awed by the analogy.  Maybe the awe was tinged with a wee bit of
anger but not much; he knows there's a hierarchy among OSs, just like
among people, and he knows where his OS stands in that hierarchy...

----

For the humour impaired, that was a joke.  To start with, I don't know
anyone called Fred.

It *is* true that I tend to ignore DOS if at all possible, especially in
my *code*.  But since I don't really use wildrepos at work, this issue
would never have come up for me, even in the DOS projects I manage.

In this case someone who's contributed a heck of a lot to the evolution
of gitolite asked, so here it is.

----

oh and in case you were wondering, DOS stands for "dominant operating
system" ;-)
2011-07-23 08:31:33 +05:30
Sitaram Chamarty 42df4c01a9 gl-dont-panic replaced by more generic gl-admin-push
(sorry Douglas Adams; the "towel day" program is no more!)
2011-07-13 22:29:44 +05:30
Sitaram Chamarty c7d95293dd revert part of 9ad7ea4
Fix a problem with authkeys perms when REPO_UMASK is too loose.

(To duplicate it, run a fresh, non-root install, and when gl-setup pops
up an editor, change the REPO_UMASK to 0007 (from the default 0077).
You'll find that ~/.ssh/authorized_keys now has g+w set, causing sshd to
refuse key-based access.)

And before you ask, even though gl-setup does it, I won't fiddle with
the permissions of an existing file in *this* code.  (gl-setup is run
manually by the admin, this one gets run on every push).

----

Side note: 9ad7ea4 was somewhat forced on me, and I didn't really agree
with parts of it.  I have no idea why I gave in so easily, but it won't
happen again!
2011-06-11 14:02:26 +05:30
miiihi f8812b7822 Allowing customization of authentication options thru gitolite.rc 2011-06-11 13:04:12 +05:30
Sitaram Chamarty 7a0f517afe sometimes you shouldn't call log_it()...
a warn/die may happen even before setup_environment() has been called,
so then log_it() tries to use uninitialised variables and it then adds
to the confusion complaining about *those*
2011-06-11 13:04:12 +05:30
Sitaram Chamarty 660fad954a make gl-system-install easier to run
make the arguments optional (with documented defaults) plus they need
not exist a priori, reducing one command (the silly mkdir!) that the
user has to run.

All this is preparatory to deprecating the from-client method.  We've
even switched the test suite to 'non-root' method now
2011-05-28 18:14:19 +05:30
Sitaram Chamarty 936f8719ce make projects.list (and some other files) writes atomic
The KDE folks have a projects.list file that gets picked up by rsync and
sent elsewhere in some cron-ish manner.  They noticed that occasionally
the file that went across was truncated, which indicates that maybe it
got picked up while it was still being written.

oh and this change also affects any files that get written using
wrap_print()
2011-05-25 08:15:36 +05:30
Sitaram Chamarty 3d9b4fae9f (minor) make htpasswd use md5 passwords
(thanks to yoonique dot net at gmail; he also tested that files with
some normal and some md5 passwords, such as would happen on an upgrade,
work fine)
2011-05-24 06:30:55 +05:30
Sitaram Chamarty 7bea99148c tighten up adc arguments a bit more 2011-05-19 09:29:47 +05:30
Sitaram Chamarty 74c1736222 (sshkeys-lint) add detection of duplicate *.pub files 2011-05-10 10:17:05 +05:30
Sitaram Chamarty 836faf915f forcibly set user.{name,email} if needed
git 1.7.4+ insists on these two being defined.  So I reduce my support
load by forcing them if they were not set.

Much easier than explaining to people what should be obvious from the
error message.
2011-05-04 14:04:10 +05:30
Sitaram Chamarty 78444c2e76 gl-system-install: optional 4th arg to help packagers
(buildroot in RPM-speak, DESTDIR in DEB-speak)

based on a patch sent by Francis Galiegue (fgaliegue at gmail)
2011-04-03 21:23:16 +05:30
Sitaram Chamarty 1006eba2fc allow the include statement to use globs
(bonus: we now have a test case for "include" itself, should it ever
decide to take an unplanned vacation!)
2011-04-01 16:11:59 +05:30
Dylan Simon 58064b8e20 Make limit on number of repos displayed by info with GL_BIG_CONFIG configurable
[doc added by Sitaram]
2011-03-30 20:27:12 +05:30
Sitaram Chamarty 0f377a7679 new doc on gitolite without ssh, plus some minor docfixes 2011-03-30 18:42:39 +05:30
Jos Houtman afc3a06c56 mirror-shell fix: setup GL_RC; post-update needs it 2011-03-21 07:51:24 +05:30
Sitaram Chamarty 6539009cb5 make REPO_BASE absolute early
$ENV{GL_REPO_BASE_ABS} is meant to point to the same directory as
$REPO_BASE, except it is meant to be passed to hooks, ADCs and other
child programs.  And since you can't be sure where the child program
starts in, this became an absolute path.

Gradually, however, I started using it wherever I needed an absolute
path (mostly in code that jumps around various directories to do stuff).
Which is silly, because there's no reason $REPO_BASE cannot also be made
an absolute, even if the rc file has a relative path.

So that's what I did now: made $REPO_BASE absolute very early on, and
then systematically changed all uses of the longer form to the shorter
form when appropriate.  And so the only thing we now use the longer one
for is to pass to child programs.

(Implementation note: The actual change is not very big, but while I was
about it I decided to make the test suite able to test with an absolute
REPO_BASE also, which is why the commit seems so large.)

----

This all started with a complaint from Damien Regad.  He had an
extremely odd setup where his bashrc changed PWD to something other than
$HOME before anything else ran.  This caused those two variables to
beceom inconsistent, and he had a 1-line fix he wanted me to apply.

I generally don't like making special fixes for for non-standard setups,
and anyway all he had to do was set the full path to REPO_BASE in the rc
file to get around this.  Which is what I told him and he very politely
left it at that.

However, this did get me thinking, and I soon realised I was needlessly
conflating "relative versus absolute" with "able to be passed to child
programs".  Fixing that solved his problem also, as a side-effect.

So I guess this is all thanks to Damien!
2011-03-21 07:51:10 +05:30
Sitaram Chamarty 32646e9cf0 (minor) make it clearer when easy install aborts
Technically this does not add any new information, but I'm hoping it
will help the folks just won't read what's on the screen otherwise.

The main impetus this time is git 1.7.4, which is strict about
user.email and user.name and rejects commits when those config variables
are not set.  As a result, the number of times gl-easy-install hits a
fatal error and bombs out without completing its job, has increased
drastically.
2011-03-13 09:37:50 +05:30
Sitaram Chamarty 3677bc5a4d one more slurp
see 9ad7ea4 -- "(minor) some changes to system(), ``, etc."
2011-03-12 04:52:34 +05:30
Sitaram Chamarty b7944ed4d1 (minor) do not purge projects.list if GL_NO_DAEMON_NO_GITWEB set
The code that sets %projlist doesn't even run if GL_NO_DAEMON_NO_GITWEB
is set, so it doesn't make sense to then *use* that (empty) variable and
effectively wipe out the projects.list file.

Thanks to m0 for asking...
2011-03-10 22:12:42 +05:30
Sitaram Chamarty 9ad7ea4e19 (minor) some changes to system(), ``, etc.
(suggested by cmyers and ryan_c on #gitolite)

Between wrap_print(), which now takes a list, and the new slurp(),
pretty much everything to do with 'cat' or 'echo' has been converted to
pure perl.

----

Personally, I consider these changes to be somewhat gratuitous, because
none of these had a security *or* a performance concern.  But since the
amount of new perl code was not too high (just the slurp() function,
really), I figure it's not a big deal to do it.
2011-03-09 20:11:30 +05:30
Sitaram Chamarty 91a8379f9f change some 'warn's to 'print STDERR' and vice versa
with warns now being logged, it's nice to make sure that anything that
could even vaguely be considered someone playing with the system, *or*
is otherwise noteworthy, be emitted as a 'warn' instead of as a 'print
STDERR'.  Similarly stuff that is clearly a syntactic warning or typo
should come from 'print STDERR', instead of from a 'warn'.
2011-03-08 14:20:35 +05:30
Carl Myers 59a1855e38 Added handler to ensure warn and die are logged
(with some extra changes by Sitaram)
2011-03-08 14:20:35 +05:30
Sitaram Chamarty 396bfaa3b9 gl-auth now checks for and run a hook called 'gl-pre-git'
see sample code for motivation; other uses at your discretion
2011-03-05 12:23:17 +05:30
Sitaram Chamarty ca913af6cd for cool 'cat's who use 'putty' :-)
ryan-c on #gitolite (ryan.castellucci@gmail.com) found that if a user
types in
        ssh git@server `echo -e "\033[2J"`
or eqvt, he can get raw ASCII control characters into gitolite's log
file.  Then if a gitolite admin 'cat's the log file (instead of using a
pager, or uses a pager in raw mode like 'less -r'), those control
characters hit his screen and do stuff.

While clearing the screen etc is probably harmless and I would not have
bothered, we know that the old vt100 would allow the keyboard to be
remapped by the server sending control codes, and we're not really sure
which of the currently in use terminals emulate this.

And finally, I found somewhere that "PuTTY allows the server to send
control codes that let it take over the mouse".  Scary...

(...of course, I hate putty/plink so I was sorely tempted to leave this
as is to punish people who use it <grin> but not really; I'd joke about
it but won't actually *do* it!)
2011-03-05 05:56:58 +05:30
Sitaram Chamarty 46528f0cc7 squelch useless "undefined" warnings
Normal users will never need this change but the big boys like to play
on the server side directly... and sometimes the SSH_CONNECTION var is
not set
2011-02-25 20:39:59 +05:30
Sitaram Chamarty 9a49487d0a minor bug in data format fixup code
Earlier, it wasn't as critical for gl-setup to be run with the full
path; the BINDIR deduction used to happen in almost every program.  Now
it's a lot more important.

Apparently I never noticed that "/bin/bash -l gl-setup" does not set $0
to the correct, fq path.  Adding a "-c" does, however...

[thanks to Jeff from the KDE team for finding this]
2011-02-25 06:20:41 +05:30
Sitaram Chamarty bc5e995078 reach out and touch someone
This shaves 3 seconds off of KDE's config compile time :-)

Yes, I know wrap_print has that extra print statement, but otherwise it
was lying around not earning its keep so I gave it a little side job :-)
2011-02-22 13:28:02 +05:30
Sitaram Chamarty dfdab0f3c8 allow gitolite_rc.mkd values to be overridden by ~/.gitolite.rc
you might wonder why these are different from all the other variables in
the rc file... it's just that I never thought people would want to
change these!
2011-02-15 15:10:29 +05:30