summaryrefslogtreecommitdiff
path: root/debconf2015.pin
blob: e7012e0847ff26fd24a3a7f20f201edca918e4a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
# Debian conference Pinpoint talk about Lua in Debian, and Gitano

[backing.png]
[center]
[font=Sans 50px]
[stretch]

-- [backing-lua.png]

-- [backing-lua.png] [no-markup]

Lua!

Daniel Silverstone <dsilvers@debian.org>

# Burble like a tard about who you are
# Talk will cover a little about Lua and where you might
# find it, what it is in Debian, etc.  Then a bit about
# My primary Lua-based project 'Gitano'

-- [backing-lua-crescent.png]

What is Lua?

# Small language, easily embedded and extended.
# From Tecgraf at PUC-Rio
# Started life as a data description language called DEL
# Grew into something called 'Sol' and from there to 'Lua'

-- [backing-lua-landing.png]

It's just that thing for games, right?

# Popular in games, such as World of Warcraft, Angry Birds,
# Later LucasArts games, Baldur's gate, BZFlag, Civ 5, Crysis,
# Far Cry, Freeciv, MDK2, Saints Row 2, The Witcher, etc.

-- [backing-lua-landing.png]

Not just for games...

# Mercedes uses it in cars, Postgres PL/Lua
# Loads of Adobe products (lightroom, Revel, etc)
# IDEs (ZeroBrane fr.ex)
# Canon Hack Development Kit
# Ginga (brazilian digital tv system middleware scripting)
# Guppy genetic sequencing
# LG smart TVs
# Space shuttle hazardous gas detection system
# Giggle (Renderman plugin developed for 'Troy')

-- [backing-lua-landed.png]

Blah blah blah, closed source software,
mumble groan complain.  What about F/LOSS?

# PowerDNS, GNUPlot, hedgewars, Apache2, widelands,
# Freespace, Weechat, tokyotyrant, pepper, pandoc,
# opendkim, monotone, lighttpd, geany, freeciv,
# devilspie, crawl, conquest, conky, awesomewm, cgit
# asterisk aegis, blahblahblah

-- [backing-lua-footprint.png]

Okay, so what is it like?

# Very simple syntax.  A little pascal like (do / end)
# First class functions, lexical scoping, one-based-index
# Simple OO syntax, but no classes per-se

-- [backing-lua-footprint.png] [font=Inconsolata 75px]

for k, v in pairs(os.environ) do
  print(k, "=", v)
end

-- [backing-lua-footprint.png]

Extending Lua

# Very simple stack-based API for interacting between
# Lua and C resulting in python-lua bridges, python-ruby
# bridges, haskell-lua support, etc.

-- [backing-lua-footprint.png] [font=Inconsolata 75px]

static int l_double(lua_State *L) {
  LUA_NUMBER value = luaL_checknumber(L, 1);
  lua_pushnumber(L, value * 2.0);
  return 1;
}

-- [backing-lua-footprint.png]

Embedding Lua

# The same simple stack-based API for interacting between
# Lua and C works the other way out...

-- [backing-lua-footprint.png] [font=Inconsolata 75px]

static LUA_NUMBER doublevalue(lua_State *L, LUA_NUMBER value) {
  LUA_NUMBER ret;
  luaL_loadstring(L, "v=... return v * 2.0");
  lua_pushnumber(L, value);
  lua_call(L, 1, 1);
  ret = luaL_checknumber(L, -1);
  lua_pop(L, 1);
  return ret;
}

-- [backing-lua-crater.png]

Batteries somewhat nearby...

# Despite popularity, batteries are still slowly accreting
# ca. 90 or so Lua library packages, many thanks to Enrico Tassi
# LuaRocks

-- [backing-lua.png]

Community?

# Small but reasonably vibrant community, in parts a little
# immature despite the age of the language, mostly because
# of how a lot of gamers get into Lua

-- [lua/fosdem-2015-lua-bof.jpg] [bottom]

Lua BoF - FOSDEM 2015

# Terrifying bunch of reprobates

-- [backing-lua.png]

Community!

IRC: <span font="Inconsolata 50px">#lua</span> on <span font="Inconsolata 50px">Freenode</span>
Website: <span font="Inconsolata 50px">http://www.lua.org/</span>
Mailing List: <span font="Inconsolata 50px">lua-l@lua.org</span>

-- [backing-lua.png]

Back to Debian ...

# Originally I packaged Lua 4 and Lua 5.0 way back in the day, but the packages
# were not very good and John Belmonte took over. The majority of Lua packaging
# in Debian is now looked after by Enrico Tassi.  Some of the main Lua packages
# are still by John Belmonte.

-- [backing-lua-crater.png]

Packaging Lua libraries

# Lua's lack of batteries mean that there are a lot of mechanisms for the
# various obvious things you need to do (e.g. posix bindings).  This means
# that we end up with a lot of libraries, often called the same thing, which
# are not mutually compatible.  Fortunately LuaRocks is sorting this kind of
# thing out.

-- [backing-lua-crater.png]

debhelper support (dh-lua)

# Worked on by Enrico Tassi, standardises build of Lua library
# packages to be policy compliant and work consistently across all
# Lua versions packaged in Debian.
# 5.1 5.2 5.3 and perhaps luajit

-- [backing-lua-crater.png] [font=Inconsolata 75px]

 #!/usr/bin/make -f
 %:
	dh $@ --build-system=lua --with lua

# Basically the trivial debhelper but including dh-lua and turning it on
# add a build-dependency on dh-lua too

-- [backing-lua-crater.png] [font=Inconsolata 75px]

 # lua5.1.lace.dh-lua.conf
 PKG_NAME=lace
 LUA_SOURCES=$(wildcard lib/lace/*.lua) lib/lace.lua
 LUA_SOURCES_MANGLER=sed s?^lib/??
 LUA_MODNAME=lace

# You have to tell dh-lua how things work to get your library into place.
# You can also tell it about tests etc, it's all in Enrico's policy.html
# in the dh-lua docs
#
# Symlink other lua versions (or make new files if they fundamentally differ)

-- [backing-lua-crescent.png]

Other peoples' build systems and how to (ab)use them.

# Thanks to Enrico's use of Make, it's possible to abuse dh-lua a little.  It's
# not really meant to include the building of binaries as well as libraries
# from the same source, but...

-- [backing-lua-crescent.png] [font=Inconsolata 75px]

PKG_NAME=supple
LUA_SOURCES=$(wildcard lib/supple/*.lua) lib/supple.lua
LUA_SOURCES_MANGLER=sed s?^lib/??
LUA_MODNAME=supple
CLIB_OBJS=lib/supple/capi.lo
VERSION_INFO=0:0:0
LUA_MODNAME_CPART=supple.capi

build:
        $(H)$(LBTL) --mode=link $(CC) $(CFLAGS) -Wl,--no-add-needed \
                -o $(UID)/wrapper -I . -I $(UID)/ \
                src/wrapper.c \
                $(LDFLAGS) $(LUA_LBTL_D)

install:
        $(H)$(LBTL) --mode=install install -m a+rx,u+rwxs \
           $(UID)/wrapper $(shell pwd)/$(LUA_LPATH)/supple-wrapper$(LUA_VERSION)
        $(H)$(LBTL) --finish $(LUA_LPATH)

# Since the dh-lua.conf files are makefiles, and some of dh-lua's targets are
# used purely as a collection points for a number of other targets, we can be
# evil and add in additional rules...

-- [backing-lua-landed.png]

What about applications written in Lua?

# Applications are a slightly different beast, currently dh-lua isn't
# interested in those.  I'm sure Enrico would love patches.

-- [backing-lua-landed.png] [font=Inconsolata 75px]

 #!/usr/bin/make -f
 
 # Set up the variables the Gitano makefile needs
 PREFIX:=/usr
 LUA_VER:=5.1
 export LUA_VER PREFIX
 
 # And Debhelper the world
 %:
         dh $@

# Sadly, providing the app's Makefile isn't too crazy, it turns out to be
# trivial to package them anyway -- thanks debhelper...

-- [backing-lua.png]

And now for something...

-- [backing-cat-flop.png]

...of a tangentially related advertisement...

-- [backing-cat-flop.png] [no-markup]

Gitano - A Git service configured in Git

# I apologise now for people who were here two years ago, but some of this
# will seem somewhat familiar as the fundamentals of Gitano haven't changed
# but I promise there's one or two new things...

-- [backing-cat-flop.png]

What is it?

# Git Server
# Written in Lua
# Configured in Git where plausible

-- [backing-cat-flop.png]

Why do it?

# Looked at gitolite (in 2012) and decided I could do
# better or nicer or whatever

-- [backing-cat-flop.png]

Who is it for?

# People who would like to run their own git server
# Github is a more effective centralised version control
# system than Subversion could ever hope to be.
# Gitlab is a large unwieldy pile of crap
# Both of them rely on data stores which are not Git

-- [backing-cat-sunbathing.png]

-- [backing-cat-sunbathing.png]

Technology choices

# Git - odd to list, but I mean configuration is in git
#       rulesets are in git, etc.etc.etc.
# Lua - I like Lua, it's easy to prototype and write stuff
# libgit2 - Way faster than invoking git commands
# although Gitano *can* operate without it
# cgit rather than gitweb - much faster, caches, prettier
# and cgit now supports extensions written in Lua

-- [backing-cat-sunbathing.png]

Lace - Lua Access Control Engine

# ACL engine for rulesets.  Most people who are at least
# technically minded understand ACLs.  Non-turing-complete
# means output more easily cached. Not using Lua means I
# *could* switch implementation language if I wanted.

-- [font=Monospace 50px]

define ref_has_user_prefix ref prefix refs/heads/${user}/
allow "User branches are okay" op_is_reffy ref_has_user_prefix

# Simple example showing definitions, prefix-matches,
# expansions (gitano specific) and permission statements.
# list of defined predicates on the allow line must all pass

-- [backing-cat-sunbathing.png]

Clod - Configuration Language Organised (by) Dots

# Designed to keep track of ordering of entries (and spaces)
# Currently doesn't track comments (because that's super
# hard) Humans and the library tend to edit files in similar
# ways meaning diffs are sane

-- [font=Monospace 50px]

project.head "refs/heads/master"
project.description "Black box testing of Unix programs"
project.owner "liw"

# Three simple string entries as might be found in a
# repository configuration in Gitano.

-- [font=Monospace 50px]

description "Gitano Instance Administrators"

members["*"] "dsilvers"
members["*"] "vince"

# Clod also supports lists which remain ordered.  This is an
# example group file in a Gitano repository

-- [backing-cat-sunbathing.png]

Supple - Sandbox [(for) Untrusted Procedure Partitioning (in) Lua] Engine

# Supple allows me to run hooks provided by project owners
# safely without risking them gaining access to the server
# in any unusual way.

# Hooks are run as Lua code with a limited set of functions
# and only the data relevant to the event they're hooking
# (along with a read-only repository object they can use to
# interrogate other things a bit)

-- [backing-cat-sunbathing.png]

To limit the attack surface...

The "untrusted" code runs in a (limited) Lua sandbox.

That sandbox is soft-limited in terms of VM opcodes and memory.

The sandbox is monitored and IO marshalled externally.

# Your "untrusted" code is run inside a Lua sandbox which
# has only a limited set of Lua's functionality exposed to
# it.

# That sandbox is soft-limited (optionally) in terms of VM
# opcodes and memory allocated by Lua

# The sandbox is run inside a monitoring Lua VM instance
# which is responsible for carefully marshalling calls etc
# into and out of the sandbox. All your comms go via this
# monitor.

-- [backing-cat-sunbathing.png]

Just in case...

The monitor is a Lua VM anyway, and it's all inside a separate process.

The sandbox process is in an ephemeral chroot.

# The monitor is, itself, a Lua VM anyway, inside a process
# which is separate from the process you're doing untrusted
# work on behalf of.

# The sandbox process is created using a rootly helper so
# that it's put into an isolation state consisting of a
# directory which is owned by root which is set as your root
# via the chroot call, but which is also rmdir'd so it's
# ephemeral. Your process drops privileges back to the
# calling UID so it cannot do anything inside its CWD
# anyway.

-- [backing-cat-sunbathing.png]

And if that's not enough...

Solid rlimits in terms of memory and open FDs

And on Linux, memory is pre-allocated and we enter seccomp mode 1.

# On top of that, the sandbox has some pretty solid rlimits
# set in terms of max CPU usage, max VM size, max FDs open,
# and max size of any file it writes. As such, it can't
# create > 0 byte files in the directory it doesn't have
# access to, and could only do that if it closed the FD to
# the host process which is its only communications avenue.

# Then, if you're on Linux, we go one step further and
# pre-allocate enough memory for the interpreter to not hit
# the rlimit and then enter seccomp mode 1 which limits the
# syscalls permissible to read, write, _exit and sigreturn
# so even if you could have circumvented any/all of the
# limits above, you now can't make syscalls to take
# advantage of them.

# Currently pondering namespaces and how I might use those to further limit
# stuff.

# If that's not sandbox enough, please tell me how to
  improve matters further.

-- [backing-cat-sunbathing.png]

Gall - Git Abstraction Layer (in) Lua

# Abstraction layer for accessing Git repositories from Lua.
# Focusses on bare repositories and can operate using the
# git commandline or the libgit2 library.  Used to be luagit2
# based but that stopped being updated so it's a very thin
# binding built as part of gall now.

-- [backing-cat-inelegant.png]

# Next comes inelegance, so "phew" goes here.

-- [backing-cat-inelegant.png]

Putting it all together.

Gitano uses all of these libraries and adds utility commands
for managing repositories, users, rules, etc.

# Using these libraries and with a small amount of code of
# its own Gitano then provides a git service with important
# additional commands such as creating and destroying
# repositories

-- [font=Monospace 50px] [no-markup]

ssh git@server create fooproject/barrepo
[example] Creating repository: fooproject/barrepo
[example] Setting repository owner to dsilvers
[example] <fooproject/barrepo> Set owner to <dsilvers>
[example] Running checks to ensure hooks etc are configured
[example] Repository fooproject/barrepo created ok.  Remember to configure rules etc.

ssh git@server help config
[example] config ---- View and change configuration for a repository (Takes a repo)
[example] 
[example] => usage: config <reponame> <cmd> [args...]
[example] => 
[example] => View and manipulate the configuration of a repository.
...


# Create a repository, ask for help about configuration
# Gitano has help built in for all its commands too

# And now for something shocking

-- [backing-cat-shocked.png]

-- [backing-cat-shocked.png]

Integrating with external apps and services

OpenSSH server, Cgit (gitweb at a pinch), git-daemon

Outgoing HTTP(s) calls from hooks

# Horrifyingly shocking idea, but integrating with external
# services is a good idea.  As such, Gitano uses OpenSSH
# (nominally any other SSH too) for authentication and
# secure connections.
# Primarily focussed on cgit, we do generate the bits needed
# for gitweb to operate too.  And we produce the
# git-daemon-export-ok file for the git daemon to be able to
# work.

-- [backing-cat-shocked.png]

Real users of Gitano

 - git.gitano.org.uk, git.liw.fi
 - git.netsurf-browser.org, richard.maw.name/git
 - Codethink and various other companies
 - Possibly some of you in the audience

# Equally horrifyingly, people use this crap what I wrote.

# But, it's not enough (sound stern)

-- [backing-cat-stern.png]

-- [backing-cat-stern.png]

Mini-debconf
  <small>mini-camp
    <small>mini-coding
      <small>mini-effort
        <small>mini-done-lane
          <small>mini-report
</small></small></small></small></small>

# Lots of work happened Thursday including incorporating git upload-archive
# support contributed by Gavin Lee of Maynooth University Ireland, various
# fixes from friendly colleagues of mine, and a huge number of niggle-fixes
# including: User renaming being fixed, group renaming being verified,
# detection of dangling HEAD following push (just for you Brett), automatic
# defines for users and groups for simpler rule creation, https support for
# hooks, correctly recording committer vs. author for remote commands using the
# 'sudo' (as) command. copying repos no longer making assumptions based on the
# default ruleset (which to be fair most people use for the most part).

-- [backing.png]

Packaging

# As you might have guessed from the earlier content, I've been packaging
# Gitano and its libraries for Debian -- Currently I have builds for Jessie
# but they're very much not ready and very much not compliant yet.
#
# Help welcomed.  Debianisation is on the Gitano gitano server as you'd expect.

-- [backing-cat-stern.png]

Future plans

Lots of ideas for future content, see the Trello

 - https://trello.com/b/l4Id6iiC/gitano
 - (Link is on https://www.gitano.org.uk/)

# I would welcome contributions to Gitano or the libraries
# behind it.  I would especially welcome contributions which
# increase the scenario test suite coverage.

-- [backing-cat-eat-you.png]

-- [backing-cat-eat-you.png]

Live demo and walkthrough

"Stand by for action!
 We are about to launch Stingray!
 Marineville - I am calling 'Battle Stations'!
 Anything can happen in the next half-hour!"

 - Commander Shore

# I make no promises, but here goes a demo which might eat
# my face.

-- [backing-cat-flop.png]

Mailing list: <span font="Monospace 50px">gitano-dev@gitano.org.uk</span>
IRC Channel: <span font="Monospace 50px">#gitano</span> on Freenode
Website: <span font="Monospace 50px">http://www.gitano.org.uk/</span>

Any questions?

-- [backing-cat-sat.png]

# Intrusive cat says "Enough with the talkings"

-- [backing-cat-sat.png]

Thank you for listening

This talk is available from:
<span font="Monospace 50px">git://git.gitano.org.uk/personal/dsilvers/gitano-talk.git</span>
(specifically debconf2015.pin)

Current (at least at time of talk) debs at:
<span font="Monospace 50px">http://platypus.pepperfish.net/~dsilvers/gitano/</span>