hacking afs dumps for fun and profit - afs & kerberos best

44
Hacking AFS Dumps for Fun and Profit Thomas L. Kula Information Technology Central Services University of Michigan 2009 AFS and Kerberos Best Practices Workshop

Upload: others

Post on 10-Feb-2022

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Hacking AFS Dumps for Fun and Profit

Thomas L. Kula

Information Technology Central Services

University of Michigan

2009 AFS and Kerberos Best Practices Workshop

Page 2: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

For some reason, I am fascinated by dumps

1

Page 3: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

2

Page 4: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

vos dump -id user.kula.backup -localauth

3

Page 5: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

What is in a volume dump

• Dump Header

• Volume Header

• Large and Small vnodes

4

Page 6: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Dump Header

• Volume ID

• Volume Name

• From Date

• To Date

5

Page 7: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Volume Header

• Volume ID

• Volume Name

• maxquota, diskused, nfile

• create/access/update/backup dates

• And other stuff

6

Page 8: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Vnodes

• Large vnodes are directories

• Small vnodes are files

• Vnode number

• Uniqifier

• Type

7

Page 9: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Vnodes

• Author/Owner/Group/Mode

• Client/Server Date

• Size

• ACL (for directories)

8

Page 10: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Vnode Contents

• The content of a small (file) vnode is the file itself

• The content of a large (directory) vnode is a blob that ties

names to vnode/uniqifier tuples

9

Page 11: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Full Dumps

• Every vnode, and the contents of every vnode, is dumped

10

Page 12: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Partial Dumps: Directories

• Every large vnode and its contents are dumped

• Unless you use -omitdirs, in which case a minimal vnode is

dumped

• It’s basically enough info to say “this vnode and uniqifier still

exists”

11

Page 13: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Partial Dumps: Files

• Every small vnode has something dumped:

– If the file has changed since -time, the full vnode and

contents are dumped

– If the file has not changed since -time, only a minimal

vnode is dumped — “This vnode and uniqifier still exists”

12

Page 14: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Some problems I’d like to solve

• What exactly is in a collection of dumps?

• Merging a full and partial dumps into a new full dump

13

Page 15: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

What exactly is in a collection of dumps

• “I need exactly this file from this date” rarely happens

• “My file last existed sometime during this week....”

14

Page 16: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Accessing metadata

• Useful to have access to metadata in a collection of dumps

• 240K volumes backed up daily, 28 days retention

• Keeping everything in one database would require a lot of

info, shoved in and pulled out daily

• We’re not fans of “The database, with everything”

• 99.99% of that data will never be used

15

Page 17: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Accessing metadata

• And yet it would be nice to have relatively quick access to

that data for users

16

Page 18: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Accessing metadata

• We have volumes that are not being touched, and are prob-

ably not even mounted anywhere

• It would be nice to identify those, and get rid of them

• find /afs/umich.edu ... seems painful

17

Page 19: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Accessing metadata — wants

• Pre-extracted metadata

• Per dump file granularity

• Easy-to-read blob

18

Page 20: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Combining full and incremental dumps

• Like many people, I have a lot of mp3s

19

Page 21: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

20

Page 22: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Combining full and incremental dumps

• Like any sane person, I keep them in AFS

21

Page 23: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

22

Page 24: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Combining full and incremental dumps

• Like any prudent person, I keep backups

23

Page 25: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Combining full and incremental dumps

• Path from colocation to home: 3 mbps

• Path from home to colocation: 768 kbps

24

Page 26: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Combining full and incremental dumps

• Doing full dump of most large volumes is painful

• am.tmbg.backup 536871739 BK 1297219 K On-lineservice-m1.tproa.net /vicepbRWrite 536871738 ROnly 0 Backup 536871739MaxQuota 5000000 KCreation Sun May 31 01:59:07 2009Copy Sun May 31 01:59:07 2009Backup Sun May 31 01:59:07 2009Last Update Sat Jan 3 11:55:14 20090 accesses in the past day (i.e., vnode references)

RWrite: 536871738 Backup: 536871739number of sites -> 1

server service-m1.tproa.net partition /vicepb RW Site

25

Page 27: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Working with dump files

• dumpscan, a tool for working with dumps

• http://dl.central.org/dl/software/dumpscan/

• Written by CMU SCS

26

Page 28: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

dumpscan

• Simplifies the mechanics of slogging through a dump

• Register callbacks to handle various dump items

• Then run a routine to scan through the dump

27

Page 29: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Changes to dumpscan

• http://kula.tproa.net/code/dumpscan-dont-call-cb dirent-twice.patch

• http://kula.tproa.net/code/xfile-gzip.patch

28

Page 30: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

My blob or yours?

• Don’t want to invent my own

• Want data to be self-contained, easy to read, standardized

29

Page 31: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

sqlite

• http://sqlite.org/

• SQLite is a software library that implements a self-contained,

serverless, zero-configuration, transactional SQL database

engine.

• APIs for C and Python

• Simple sql client

30

Page 32: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

afsdump sqlite

• Pulls metadata from dump

• afs dump header

• afs vol header

• afs vnode

• afs dir ent

31

Page 33: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

afsdump sqlite

• Embarrassingly simple use of sqlite

• Simple tables of data

• Tables designed to be concatenated

• “Trivial” to use your DB of choice

32

Page 34: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

afsdump sqlite

• Hackish

• Not particularly robust

• It works until it doesn’t

33

Page 35: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

afsdump sqlite.py

• Rough framework of Python

• Deals with dumps and collections of dumps

• Even more hackish

• Highly incomplete

34

Page 36: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

lslr.py

• Proof-of-concept

• ls -R on a collection of dumps

• You don’t even want to know how hackish this is

35

Page 37: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

./lslr.py /home/kula/u.kula.backup.1163749800-0-0.sqlite \/home/kula/u.kula.backup.1235778854-1163749800-1.sqlite \/home/kula/u.kula.backup.1240557814-1235778854-2.sqlite

36

Page 38: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

from dump u.kula.backup.1240557814-1235778854-2 directory ( 1 , 1 ) .DIR ( 1 , 1 ) from dump u.kula.backup.1240557814-1235778854-2 : u’.’DIR ( 1 , 1 ) from dump u.kula.backup.1240557814-1235778854-2 : u’..’...FILE ( 378 , 2384 ) from dump u.kula.backup.1235778854-1163749800-1 : u’.muttrc’FILE ( 388 , 1388 ) from dump u.kula.backup.1163749800-0-0 : u’.profile’...SYMLINK ( 540 , 2866 ) from dump u.kula.backup.1163749800-0-0 :u’iastate-stuff’ links to u’#iastate.edu:user.kula.’

...from dump u.kula.backup.1240557814-1235778854-2 directory ( 9 , 1363 ) ./.sshDIR ( 9 , 1363 ) from dump u.kula.backup.1240557814-1235778854-2 : u’.’DIR ( 1 , 1 ) from dump u.kula.backup.1240557814-1235778854-2 : u’..’FILE ( 2740 , 7555 ) from dump u.kula.backup.1235778854-1163749800-1 : u’config’

37

Page 39: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Conceptualized Merge Tool

• Run afsdump sqlite on dump(s)

• Run create dump manifest

• Run merge dumps: dumps + manifest = new dump

38

Page 40: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Other potentially useful tools

• volume dump merge equivalent of “vos split”

• Puffs/FUSE, allow a collection of dumps to be mounted RO

as a local disk?

39

Page 41: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Code

• Canonical GIT repository

• /afs/tproa.net/public/code/afsdump sqlite/afsdump sqlite.git/

40

Page 42: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Thanks Ugly Mug Cafe

2009-05-31 0.65 Coffee refill, Tanzanian2009-05-31 1.59 Coffee, Tanzanian2009-05-30 0.65 Coffee refill, Brazil2009-05-30 0.65 Coffee refill, Brazil2009-05-30 1.59 Coffee, Brazil2009-05-29 0.65 Coffee refill, Ethiopian2009-05-29 0.65 Coffee refill, Ethiopian2009-05-29 1.59 Coffee, Ethiopian2009-05-29 3.02 Trad. cap.2009-05-27 2.17 Rooibos2009-05-26 2.17 Rooibos, iced2009-05-25 2.17 Rooibos, iced2009-05-25 1.59 Coffee, Burundi2009-05-24 1.59 Coffee, Brazil2009-05-23 2.17 Rooibos, iced2009-05-23 0.65 Coffee refill, Burundi2009-05-23 1.59 Coffee, Burundi2009-05-23 2.12 Espresso

41

Page 43: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Hacking AFS Dumps for Fun and Profit

Thomas L. Kula

Information Technology Central Services

University of Michigan

[email protected][email protected]

2009 AFS and Kerberos Best Practices Workshophttp://kula.tproa.net/talks/afskbpw2009/

Page 44: Hacking AFS Dumps for Fun and Profit - AFS & Kerberos Best

Media Credits

• “Waste dump Tanjung Priok Jakarta Indonesia”

http://commons.wikimedia.org/wiki/File:Waste dump - Jakarta - Indonesia.jpg

by http://commons.wikimedia.org/wiki/User:Hullie

Licensed under Creative Commons Attribution ShareAlike2.5

http://creativecommons.org/licenses/by-sa/2.5/