SlideShare une entreprise Scribd logo
1  sur  58
Télécharger pour lire hors ligne
The Ruby Guide to
*nix Plumbing
Haxor Redux Edition


http://slides.games-with-brains.net
caveat lector
 danger! we’re entering strange territory
 and our guide is no Alan Quartermain
 the map is missing some major landmarks
 and is riddled with inaccuracies
 so don’t try this on a live production system
 and read your man pages thoroughly
cowgirl for hire
                      Eleanor McHugh
                   eleanor@games-with-brains.com


                    usual haunts include

                           ruby-talk
                             LRUG
                            devchix
                         conferences
systems programming
it’s our right as coders to get low-level
and we shouldn’t have to use C to do it
worse is better
the unix philosophy of life
it’s smart to be lazy
 create small tools
 to solve simple tasks effectively
 perform each task independently
 and pass the results from one task to another
 using a clean interface
 thus solving complex problems sociably
knife goes in...
only build what we need
reuse what we already have
change our tools as [des|requ]ired
stay flexible
...guts come out
cohesive device model
kernel
shell
userspace
could it get more punk?
“if you give people the license to be as
outrageous as they want in absolutely any
fashion they can dream up, they’ll be creative
about it, and do something good besides”
                                    - Lester Bangs
the process
a discrete unit of work
anatomy of a process
program instructions
program data
system data (file descriptors, user, group, parent, etc.)
environment data
supports one or more threads of execution
preemptively scheduled by the kernel
process creation
a process may spawn child processes via fork()
this creates a duplicate child process
with duplicate file descriptors and program state
which can be replaced via exec() of a new program
all processes ultimately derive from the init process
which is created by the kernel at boot
a costly strategy
 sometimes we only want a blank slate process
 but fork() copies the full process state
 so BSD introduced vfork() which shares data memory
 whilst POSIX introduced spawn()
 most fork() implementations now use copy-on-write
 so the advantages of vfork() have diminished
with certain limitations
 only the thread which forks will be in the child process
 a system based on green threads can work around this
 Ruby 1.8 still uses pthreads so doesn’t
 it’s also possible for exec() to fail
 so forked processes need to think about this
 and return meaningful exit() codes
Kernel.system [env ,] cmnd [, args] [, options] => true or false or nil
Kernel.spawn [env ,] cmnd [, args] [, options] => pid
The simplest way to take advantage of multiple processes in Ruby is to
launch a subshell and either block until it terminates or keep a note of its
process ID so this can be checked later. This is an opaque method and
not useful when the parent process wishes to capture results.

Kernel.` command ` => string
%x{ command } => string
The next step up in utility from system() and spawn(), the backquote
method captures standard output from the subshell and as a bonus
stores a Process::Status object in the thread-global $? variable.
IO.popen cmd [, mode = "r"] => io
IO.popen cmd [, mode = "r" [{ | io | block }] => obj
Invokes a command shell in a subprocess and executes the specified
commands, providing a [uni|bi]directional pipe which the parent process
can use to communicate with the subprocess.

Open3.popen3 cmd [{ |stdin, stdout, stderr| block }]
Open3.popen3 cmd => array
A wrapper for spawn() which provides access to the standard IO streams
of the subshell along with a thread waiting on it.
Kernel.fork [{ block }] => fixnum or nil
Process.fork [{ block }] => fixnum or nil
Ruby provides its own fork() implementation which can either take a
block and run it in a subprocess, or can allow a more traditional split in
execution paths. No IPC mechanism is provided beyond allowing the
parent to wait on the child process and receive an error code.

Kernel.exec [env ,] cmnd [, args] [, options]
And as you’d expect it also allows access to the exec() family of system
calls. This is a rare core library methods which doesn’t return a value for
the simple reason that the existing program ceases to exist unless an
error occurs, and that’s flagged with a SystemCallError exception. It’s
common practice to terminate the program or retry exec() after a delay.
zombie want brains
a zombie is a subprocess which outlives its parent
zombies are members of the system process group
and are eventually terminated
but until then they retain system resources
and may not flush all of their IO buffers
so get in the habit of flushing IO buffers regularly
Process.wait2 => [ int, Process::status ]
Prcess.waitpid2 pid, [ int = 0 ] => [ int, Process::status ]
Prcess.waitall => [ [ int, Process::status ] *]
Wait for a child process to exit. Wait2 watches all child processes and
returns when any one process exits whilst waitpid2 waits for a specified
child process, optionally masking for WNOHANG and WUNTRACED.
Waitall waits on all child processes to exit and returns their statuses.
the shell
the glue that holds the system together
standard shells
 provide an interactive environment on std[in|out|err]
 using an interpreted language
 for job control and file system manipulation
 the bourne shell is the lowest common denominator
 with a powerful POSIX-compatible syntax
 which is a pig to parse or maintain
the Ruby way
shell.rb ships with the standard library
provides redirection, piping and standard commands
  tee, cat, echo, pwd, [push|pop]d
enumerates files and directories with foreach
as well as wrapping arbitrary system commands
documented in The Ruby Way
the unix kernel
an overview with a Ruby twist
basic services
 virtual memory
 process management
 hierarchical file system
 user permissions
 interprocess communication
 signals and interrupts
 execution environment
file descriptors
 the kernel keeps a table of open files for each process
 an integer index is used to reference entries
 and is known as a file descriptor
 unix is liberal about what counts as a file
 and most descriptors are inherited by child processes
 caution file semantics can vary...
beware the subtleties
 file descriptors are unique to a process
 so closing a descriptor only affects that process
 but the underlying descriptions are shared
 performing an lseek() changes the description
 and therefore will affect other processes
 with much hilarity ensuing...
IO.sysopen path [, mode [, perm] => fixnum
io.sysread int [, buffer] => string
io.syswrite string => int
io.sysseek offset, whence = SEEK_SET => int
These methods make direct calls to the kernel to open and manipulate
the contents of files, bypassing buffering. They shouldn’t be used with
higher-level methods such as IO#read as unpredictable results may occur.

Errors are raised as Exceptions in the Errno namespace.
IO.new fd [, mode] [, opt] => io
IO.for_fd fd [, mode] [, opt] => io
Returns a new IO object (a stream) for the given IO object or integer file
descriptor and mode string. See also IO#fileno and IO.for_fd.

  a = IO.new(2,"w")     # '2' is the unix default for standard error
  $stderr.print "Hello"
  a.print " World"
  STDERR.print “!!”

produces:

  Hello World!!
require 'fcntl'
filemode = Fcntl::O_CREAT | Fcntl::O_RDWR | Fcntl::O_APPEND
descriptor = IO.sysopen “test.dat”, filemode
file = IO.new descriptor
file.syswrite “hello”
file.sysseek 0
$stdout.puts file.sysread(10)

produces:
  hello
handling many files at once

file access is much slower than memory access
this causes threads and processes to block
so usually IO is buffered by the kernel
and non-blocking access methods are implemented
however this is still ineffient when writing servers
select rd_ary [, wrt_ary] [, err_ary] [, timeout] => array or nil
Select is the standard low-level method for polling many IO streams at
once and it’s a blocking call, hence the need for a timeout. For writing
socket servers etc. this usually works reasonably well and Ruby’s
implementation plays nicely with threads.
kernel event queues
allow the kernel to raise events for streams
a process can then poll for events without blocking
on BSD this is handled by kqueue
on Linux by epoll and inotify
epoll is much more efficient than inotify
EventMachine uses these when available
syscall
calling functions in the kernel
from the docs
Kernel#syscall fixnum [, args...] => integer
Calls the operating system function identified by fixnum, passing in the
arguments, which must be either String objects, or Integer objects that
ultimately fit within a native long. Up to nine parameters may be passed
(14 on the Atari-ST). The function identified by fixnum is system
dependent. On some Unix systems, the numbers may be obtained from a
header file called syscall.h.

  syscall 4, 1, “hellon”, 6 # ‘4’ is write(2) on our box

produces:

  hello
finding your syscall codes

 MacOS X
   /usr/include/sys/syscall.h
 Linux
   /usr/include/asm/unistd_32.h
   /usr/include/asm/unistd_64.h
a fragile approach
 the native syscall is a very primitive interface
   error codes
   file descriptors & pointer addresses
   modifiable buffers
 ruby syscall doesn’t support modifiable buffers
 but it does wrap errors as Errno exceptions
IO.sysx the hard way
On MacOS X

  file = syscall 5, “test.dat”, 1      # open O_WRONLY (fcntl.h)
  syscall 4, file, “some textn”, 10   # write
  syscall 3, file, “”, 5               # read
  syscall 6, file                      # close

produces:
  Errno::EFAULT: Bad address          should be Errno::EBADF
complex parameters
some kernel calls accept structured data types
ruby represents these as String objects
which can be prepared with Array#pack
or Joel VanderWerf’s bit-struct library
both approaches allow embedded nulls
but on 1.9 remember to use 8-bit ASCII encoding
currently broken
On Ruby 1.8.7 or 1.9.1 (upto patch 129)

  syscall 4, 1, “hellon#{0.chr}goodbyen”, 15

produces:

  ArgumentError: string contains null byte
     from (irb):1:in `syscall'
     from (irb):1
     from /usr/local/bin/irb19:12:in `<main>'
Interprocess Communication

IPC objects have descriptors like files
but they don’t need to exist in the file system
System V uses keys to identify IPC objects
which are generated from paths using ftok()
POSIX uses paths to identify IPC objects
signals
 an abstraction for software interrupts
 SIGTERM and SIGKILL are the best known
 but *nixen provide a wide range of signals
 which can be used for cheap IPC
 ruby handles all of these via the Signal core class
 which allows you to write traps on individual signals
sockets
two varieties: domain sockets and network sockets
Ruby provides a rich class hierarchy
check out my other presentations for code examples
some gotchas like DNS reverse lookup as default
and Ruby doesn’t support kernel event queues
but generally robust for ad hoc data streaming
pipes

pipes provide a pair of end-points for processes to talk
an unnamed pipe connects two related processes
a named pipe lives in the file system
it has user permissions (restricted by umask)
and persists independently of processes
IO.pipe => read_file, write_file
Ruby supports anonymous pipes, which can be used to communicate
between a parent a child process, taking advantage of the fact that the
file descriptors for the end-points will exist across a fork().

Good practice is for the parent process to close the reading end of the
pipe whilst the child closes the writing end as soon as they return from
fork() and the child should also close the reading end before it terminates
to ensure buffered data is properly flushed.
named pipes
process 1                                     process 2

  File.umask 0                                File.umask 0
  MKFIFO = 132                                MKFIFO = 132
  syscall MKFIFO, fifo_name, 0666              syscall MKFIFO, “client”, 0666
  fd = IO.sysopen “server”, File::RDONLY      fd = IO.sysopen "server", File::WRONLY
  server = File.new fd, "r"                   server = IO.new fd, "w"
  client_name = server.gets.chomp             server.puts fifo_name
  puts "#{Time.now}: [#{client_name}]"        server.puts "hello world!"
  fd = IO.sysopen client_name, File::WRONLY   server.close
  client = IO.new fd, "w"                     fd = IO.sysopen “client”, File::RDONLY
  message = server.gets.chomp                 client = IO.new fd, "r"
  client.puts message.reverse                 puts client.gets
  client.close                                client.close
  server.close                                File.delete “client”
  File.delete “server”
semaphores

exist independently of processes
provide blocking access
allowing processes to be synchronised
live in the file system and have a file descriptor
usable from Ruby with syscall
posix semaphores
process 1                                            process 2

  require ‘fcntl’                                      Open, Wait, TryWait, Post = 268, 271, 272, 273
  Open, Wait, Post, Close = 268, 271, 273, 269         s = syscall Open, “/tmp/s”
  s = syscall Open, “/tmp/s”, Fcntl::O_CREAT, 1911     begin
  syscall Wait, s                                           t = Time.now
  puts “locked at #{Time.now}”                              syscall TryWait, s
  sleep 50                                                  puts “locked at #{t}”
  puts “posted at #{Time.now}”                         rescue Exception => e
  syscall Post, s                                           puts “busy at #{t}”
  syscall Close, s                                          syscall Wait, s
                                                            puts “waited #{Time.now - t} seconds”
                                                       end


produces:                                            produces:
  locked at Thu May 28 01:03:23 +0100 2009             busy at Thu May 28 01:03:36 +0100 2009
  posted at Thu May 28 01:04:13 +0100 2009             waited 47.056508 seconds
in the works
shared memory
message queues
managed platform access
memory buffers
structs
c runtime access
ruby/dl
the unsung hero of MRI
in the standard library
 introduced in ruby 1.8
 but poorly documented and lightly used
 provides access to dynamically loaded libraries
 supports managed C-style memory access
 and callback functions written in Ruby
 a viable alternative to the extension API
memory management
memory pointers encapsulated by DL::PtrData
garbage collected
  uses free() or a custom deallocator
  handles realloc() automatically
plays nicely with ruby strings and arrays
  [String|Array].to_ptr
  PtrData.struct! and PtrData.union!
using native syscall
require ‘dl’
libc = DL.dlopen(‘libc.dylib’)
open = libc[‘syscall’, ‘IISI’]
write = libc[‘syscall’, ‘IIISI’]
read = libc[‘syscall’, ‘IIIsI’]
close = libc[‘syscall’, ‘III’]      produces:
file = open.call 5, “test.dat”, 1       [3, [5, "test.dat", 1]]
write.call 4, file[0], “textn”, 5      [5, [4, 3, "textn", 5]]
close.call 6, file[0]                   [0, [6, 3]]
file = open.call 5, “test.dat”, 0       [3, [5, "test.dat", 0]]
buffer = DL.malloc(10)
read.call(3, file[0], buffer, 10)       [5, [3, 3, "textn", 10]]
close.call 6, file[0]                   [0, [6, 3]]
with a procedural slant
require ‘dl’                                            file = open “test.dat”, 0x0209
CRT = DL.dlopen ‘libc.dylib’                            write file, “textn”
F = ‘syscall’                                           close file

def open file, mode                                      file = open “test.dat”, 0x0000
     CRT[F, ‘IISI’].call(5, file, mode)[0]               text = read file, 10
end                                                     close file

def write fd, string, bytes = string.length
    CRT[F, ‘IIISI’].call(4, fd, string, bytes)[0]
end

def read fd, bytes = 1
     buffer = DL.malloc(bytes)
     CRT[F, ‘IIIsI’].call(3, fd, buffer, bytes)[1][2]
end

def close fd
     CRT[F, ‘III’].call(6, fd)[0]
end
worth checking out
ruby-ffi
RubyInline
wilson
the bluffer’s reading list

 http://slides.games-with-brains.net

 http://www.jbrowse.com/text/rdl_en.html

 http://www.kegel.com/c10k.html

 http://www.ecst.csuchico.edu/~beej/guide/ipc/

 http://beej.us/guide/bgnet/

 http://wiki.netbsd.se/kqueue_tutorial
QEMFD?
find out at Lone Star Ruby Conf 2009
QEMFD?
http://slides.games-with-brains.net

Contenu connexe

Tendances

Workflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large EnterprisesWorkflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large EnterprisesPuppet
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programmingMohammed Farrag
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationMohammed Farrag
 
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security FrameworkLecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security FrameworkMohammed Farrag
 
Bypassing anti virus scanners
Bypassing anti virus scannersBypassing anti virus scanners
Bypassing anti virus scannersmartacax
 
Hs P005 Reflective Dll Injection
Hs P005 Reflective Dll InjectionHs P005 Reflective Dll Injection
Hs P005 Reflective Dll InjectionKarlFrank99
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operationsgrim_radical
 
Death matchtournament del2014
Death matchtournament del2014Death matchtournament del2014
Death matchtournament del2014Nabil Munawar
 
Scale11x lxc talk
Scale11x lxc talkScale11x lxc talk
Scale11x lxc talkdotCloud
 
Hadoop: Code Injection, Distributed Fault Injection
Hadoop: Code Injection, Distributed Fault InjectionHadoop: Code Injection, Distributed Fault Injection
Hadoop: Code Injection, Distributed Fault InjectionCloudera, Inc.
 
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)Pixie Labs
 
PE Packers Used in Malicious Software - Part 1
PE Packers Used in Malicious Software - Part 1PE Packers Used in Malicious Software - Part 1
PE Packers Used in Malicious Software - Part 1amiable_indian
 
Troubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversTroubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversSatpal Parmar
 
Make container without_docker_7
Make container without_docker_7Make container without_docker_7
Make container without_docker_7Sam Kim
 

Tendances (19)

Workflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large EnterprisesWorkflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large Enterprises
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programming
 
Lecture1 Introduction
Lecture1  IntroductionLecture1  Introduction
Lecture1 Introduction
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administration
 
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security FrameworkLecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
 
Bypassing anti virus scanners
Bypassing anti virus scannersBypassing anti virus scanners
Bypassing anti virus scanners
 
Hs P005 Reflective Dll Injection
Hs P005 Reflective Dll InjectionHs P005 Reflective Dll Injection
Hs P005 Reflective Dll Injection
 
D trace kde4presentation
D trace kde4presentationD trace kde4presentation
D trace kde4presentation
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operations
 
[ArabBSD] Unix Basics
[ArabBSD] Unix Basics[ArabBSD] Unix Basics
[ArabBSD] Unix Basics
 
Unix lab manual
Unix lab manualUnix lab manual
Unix lab manual
 
Death matchtournament del2014
Death matchtournament del2014Death matchtournament del2014
Death matchtournament del2014
 
Scale11x lxc talk
Scale11x lxc talkScale11x lxc talk
Scale11x lxc talk
 
Hadoop: Code Injection, Distributed Fault Injection
Hadoop: Code Injection, Distributed Fault InjectionHadoop: Code Injection, Distributed Fault Injection
Hadoop: Code Injection, Distributed Fault Injection
 
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
No instrumentation Golang Logging with eBPF (GoSF talk 11/11/20)
 
PE Packers Used in Malicious Software - Part 1
PE Packers Used in Malicious Software - Part 1PE Packers Used in Malicious Software - Part 1
PE Packers Used in Malicious Software - Part 1
 
Troubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversTroubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device Drivers
 
Sudo
SudoSudo
Sudo
 
Make container without_docker_7
Make container without_docker_7Make container without_docker_7
Make container without_docker_7
 

En vedette

SGP
SGPSGP
SGPJosh
 
Itd project 1
Itd project 1Itd project 1
Itd project 1Momo Poyi
 
Introduction To Computer Aided Drafting And Design
Introduction To Computer Aided Drafting And DesignIntroduction To Computer Aided Drafting And Design
Introduction To Computer Aided Drafting And DesignHites
 
Ganaka Engineers Architect
Ganaka Engineers ArchitectGanaka Engineers Architect
Ganaka Engineers ArchitectAmir Haldive
 
Dm p lhosp(1)
Dm p lhosp(1)Dm p lhosp(1)
Dm p lhosp(1)bhattbhai
 
ASHRAE Standard 62.1 2010 Table 6.1
ASHRAE Standard 62.1 2010 Table 6.1ASHRAE Standard 62.1 2010 Table 6.1
ASHRAE Standard 62.1 2010 Table 6.1erik chiang
 
Practical plumbing design guide
Practical plumbing design guidePractical plumbing design guide
Practical plumbing design guideamr salem
 
IS 13920 1993 ductile detailing of RCC structures subjected to seismic force...
IS 13920 1993  ductile detailing of RCC structures subjected to seismic force...IS 13920 1993  ductile detailing of RCC structures subjected to seismic force...
IS 13920 1993 ductile detailing of RCC structures subjected to seismic force...RAJESH JAIN
 
HVAC Training at MEP Centre
HVAC Training at MEP CentreHVAC Training at MEP Centre
HVAC Training at MEP CentreMEP Centre
 
Ch 1: Introduction and Math Concepts
Ch 1:  Introduction and Math ConceptsCh 1:  Introduction and Math Concepts
Ch 1: Introduction and Math ConceptsScott Thomas
 
Ch 32 Radiation, Nuclear Energy, and Particles
Ch 32 Radiation, Nuclear Energy, and ParticlesCh 32 Radiation, Nuclear Energy, and Particles
Ch 32 Radiation, Nuclear Energy, and ParticlesScott Thomas
 
Chapter 18 Lenses And Refraction
Chapter 18   Lenses And RefractionChapter 18   Lenses And Refraction
Chapter 18 Lenses And RefractionGalen West
 
2012 ASHRAE HANDBOOK: HVAC SYSTEMS AND EQUIPMENT
2012 ASHRAE HANDBOOK: HVAC SYSTEMS AND EQUIPMENT2012 ASHRAE HANDBOOK: HVAC SYSTEMS AND EQUIPMENT
2012 ASHRAE HANDBOOK: HVAC SYSTEMS AND EQUIPMENTNorrazman Zaiha Zainol
 
Ch 20 Electric Circuits
Ch 20 Electric CircuitsCh 20 Electric Circuits
Ch 20 Electric CircuitsScott Thomas
 
Heating, Ventilating and Air Conditional: Analysis and Design 6th Ed
Heating, Ventilating and Air Conditional: Analysis and Design 6th EdHeating, Ventilating and Air Conditional: Analysis and Design 6th Ed
Heating, Ventilating and Air Conditional: Analysis and Design 6th Edaakumawa
 
QAQC MEP HVAC INSPECTOR
QAQC MEP HVAC INSPECTORQAQC MEP HVAC INSPECTOR
QAQC MEP HVAC INSPECTORMurugan Pillai
 
Top 8 hvac engineer resume samples
Top 8 hvac engineer resume samplesTop 8 hvac engineer resume samples
Top 8 hvac engineer resume samplesjomcoret
 

En vedette (20)

SGP
SGPSGP
SGP
 
Manual for drafting of GRI G4 reports
Manual for drafting of GRI G4 reportsManual for drafting of GRI G4 reports
Manual for drafting of GRI G4 reports
 
Itd project 1
Itd project 1Itd project 1
Itd project 1
 
Introduction To Computer Aided Drafting And Design
Introduction To Computer Aided Drafting And DesignIntroduction To Computer Aided Drafting And Design
Introduction To Computer Aided Drafting And Design
 
Ganaka Engineers Architect
Ganaka Engineers ArchitectGanaka Engineers Architect
Ganaka Engineers Architect
 
Dm p lhosp(1)
Dm p lhosp(1)Dm p lhosp(1)
Dm p lhosp(1)
 
ASHRAE Standard 62.1 2010 Table 6.1
ASHRAE Standard 62.1 2010 Table 6.1ASHRAE Standard 62.1 2010 Table 6.1
ASHRAE Standard 62.1 2010 Table 6.1
 
Practical plumbing design guide
Practical plumbing design guidePractical plumbing design guide
Practical plumbing design guide
 
IS 13920 1993 ductile detailing of RCC structures subjected to seismic force...
IS 13920 1993  ductile detailing of RCC structures subjected to seismic force...IS 13920 1993  ductile detailing of RCC structures subjected to seismic force...
IS 13920 1993 ductile detailing of RCC structures subjected to seismic force...
 
HVAC Training at MEP Centre
HVAC Training at MEP CentreHVAC Training at MEP Centre
HVAC Training at MEP Centre
 
Ch 1: Introduction and Math Concepts
Ch 1:  Introduction and Math ConceptsCh 1:  Introduction and Math Concepts
Ch 1: Introduction and Math Concepts
 
Ch 32 Radiation, Nuclear Energy, and Particles
Ch 32 Radiation, Nuclear Energy, and ParticlesCh 32 Radiation, Nuclear Energy, and Particles
Ch 32 Radiation, Nuclear Energy, and Particles
 
HVAC Fundamentals
HVAC  FundamentalsHVAC  Fundamentals
HVAC Fundamentals
 
Chapter 18 Lenses And Refraction
Chapter 18   Lenses And RefractionChapter 18   Lenses And Refraction
Chapter 18 Lenses And Refraction
 
2012 ASHRAE HANDBOOK: HVAC SYSTEMS AND EQUIPMENT
2012 ASHRAE HANDBOOK: HVAC SYSTEMS AND EQUIPMENT2012 ASHRAE HANDBOOK: HVAC SYSTEMS AND EQUIPMENT
2012 ASHRAE HANDBOOK: HVAC SYSTEMS AND EQUIPMENT
 
Ch 20 Electric Circuits
Ch 20 Electric CircuitsCh 20 Electric Circuits
Ch 20 Electric Circuits
 
Heating, Ventilating and Air Conditional: Analysis and Design 6th Ed
Heating, Ventilating and Air Conditional: Analysis and Design 6th EdHeating, Ventilating and Air Conditional: Analysis and Design 6th Ed
Heating, Ventilating and Air Conditional: Analysis and Design 6th Ed
 
QAQC MEP HVAC INSPECTOR
QAQC MEP HVAC INSPECTORQAQC MEP HVAC INSPECTOR
QAQC MEP HVAC INSPECTOR
 
Ductile detailing
Ductile detailingDuctile detailing
Ductile detailing
 
Top 8 hvac engineer resume samples
Top 8 hvac engineer resume samplesTop 8 hvac engineer resume samples
Top 8 hvac engineer resume samples
 

Similaire à The Ruby Guide to *nix Plumbing: Hax0R R3dux

LXC Containers and AUFs
LXC Containers and AUFsLXC Containers and AUFs
LXC Containers and AUFsDocker, Inc.
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administrationvceder
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device driversAlexandre Moreno
 
Unix Shell and System Boot Process
Unix Shell and System Boot ProcessUnix Shell and System Boot Process
Unix Shell and System Boot ProcessArvind Krishnaa
 
Concurrent Programming with Ruby and Tuple Spaces
Concurrent Programming with Ruby and Tuple SpacesConcurrent Programming with Ruby and Tuple Spaces
Concurrent Programming with Ruby and Tuple Spacesluccastera
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory AnalysisMoabi.com
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNoSuchCon
 
Linux@assignment ppt
Linux@assignment pptLinux@assignment ppt
Linux@assignment pptRama .
 
Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]RootedCON
 
Intro To .Net Threads
Intro To .Net ThreadsIntro To .Net Threads
Intro To .Net Threadsrchakra
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with PuppetAlessandro Franceschi
 
What Linux can learn from Solaris performance and vice-versa
What Linux can learn from Solaris performance and vice-versaWhat Linux can learn from Solaris performance and vice-versa
What Linux can learn from Solaris performance and vice-versaBrendan Gregg
 
Slot02 concurrency1
Slot02 concurrency1Slot02 concurrency1
Slot02 concurrency1Viên Mai
 

Similaire à The Ruby Guide to *nix Plumbing: Hax0R R3dux (20)

LXC Containers and AUFs
LXC Containers and AUFsLXC Containers and AUFs
LXC Containers and AUFs
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administration
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
 
Unix Shell and System Boot Process
Unix Shell and System Boot ProcessUnix Shell and System Boot Process
Unix Shell and System Boot Process
 
Concurrent Programming with Ruby and Tuple Spaces
Concurrent Programming with Ruby and Tuple SpacesConcurrent Programming with Ruby and Tuple Spaces
Concurrent Programming with Ruby and Tuple Spaces
 
.ppt
.ppt.ppt
.ppt
 
Systemcall1
Systemcall1Systemcall1
Systemcall1
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
 
Linux@assignment ppt
Linux@assignment pptLinux@assignment ppt
Linux@assignment ppt
 
Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]
 
Linux
LinuxLinux
Linux
 
Intro To .Net Threads
Intro To .Net ThreadsIntro To .Net Threads
Intro To .Net Threads
 
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
 
Linux Programming
Linux ProgrammingLinux Programming
Linux Programming
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
 
Activity 5
Activity 5Activity 5
Activity 5
 
What Linux can learn from Solaris performance and vice-versa
What Linux can learn from Solaris performance and vice-versaWhat Linux can learn from Solaris performance and vice-versa
What Linux can learn from Solaris performance and vice-versa
 
concurrency
concurrencyconcurrency
concurrency
 
Slot02 concurrency1
Slot02 concurrency1Slot02 concurrency1
Slot02 concurrency1
 

Plus de Eleanor McHugh

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdfEleanor McHugh
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsEleanor McHugh
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityEleanor McHugh
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]Eleanor McHugh
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveEleanor McHugh
 
Go for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionGo for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionEleanor McHugh
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]Eleanor McHugh
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with goEleanor McHugh
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored SpacesEleanor McHugh
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignEleanor McHugh
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by designEleanor McHugh
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trustEleanor McHugh
 
Going Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoGoing Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoEleanor McHugh
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleEleanor McHugh
 
Go for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd editionGo for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd editionEleanor McHugh
 
Going Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoGoing Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoEleanor McHugh
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goEleanor McHugh
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountabilityEleanor McHugh
 

Plus de Eleanor McHugh (20)

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient Collections
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data Integrity
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's Perspective
 
Go for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionGo for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd edition
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with go
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored Spaces
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By Design
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by design
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trust
 
Going Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoGoing Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google Go
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at Scale
 
Hello Go
Hello GoHello Go
Hello Go
 
Go for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd editionGo for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd edition
 
Going Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoGoing Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with Go
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in go
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountability
 

Dernier

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 

Dernier (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 

The Ruby Guide to *nix Plumbing: Hax0R R3dux

  • 1. The Ruby Guide to *nix Plumbing Haxor Redux Edition http://slides.games-with-brains.net
  • 2. caveat lector danger! we’re entering strange territory and our guide is no Alan Quartermain the map is missing some major landmarks and is riddled with inaccuracies so don’t try this on a live production system and read your man pages thoroughly
  • 3. cowgirl for hire Eleanor McHugh eleanor@games-with-brains.com usual haunts include ruby-talk LRUG devchix conferences
  • 4. systems programming it’s our right as coders to get low-level and we shouldn’t have to use C to do it
  • 5. worse is better the unix philosophy of life
  • 6. it’s smart to be lazy create small tools to solve simple tasks effectively perform each task independently and pass the results from one task to another using a clean interface thus solving complex problems sociably
  • 7. knife goes in... only build what we need reuse what we already have change our tools as [des|requ]ired stay flexible
  • 8. ...guts come out cohesive device model kernel shell userspace
  • 9. could it get more punk? “if you give people the license to be as outrageous as they want in absolutely any fashion they can dream up, they’ll be creative about it, and do something good besides” - Lester Bangs
  • 10. the process a discrete unit of work
  • 11. anatomy of a process program instructions program data system data (file descriptors, user, group, parent, etc.) environment data supports one or more threads of execution preemptively scheduled by the kernel
  • 12. process creation a process may spawn child processes via fork() this creates a duplicate child process with duplicate file descriptors and program state which can be replaced via exec() of a new program all processes ultimately derive from the init process which is created by the kernel at boot
  • 13. a costly strategy sometimes we only want a blank slate process but fork() copies the full process state so BSD introduced vfork() which shares data memory whilst POSIX introduced spawn() most fork() implementations now use copy-on-write so the advantages of vfork() have diminished
  • 14. with certain limitations only the thread which forks will be in the child process a system based on green threads can work around this Ruby 1.8 still uses pthreads so doesn’t it’s also possible for exec() to fail so forked processes need to think about this and return meaningful exit() codes
  • 15. Kernel.system [env ,] cmnd [, args] [, options] => true or false or nil Kernel.spawn [env ,] cmnd [, args] [, options] => pid The simplest way to take advantage of multiple processes in Ruby is to launch a subshell and either block until it terminates or keep a note of its process ID so this can be checked later. This is an opaque method and not useful when the parent process wishes to capture results. Kernel.` command ` => string %x{ command } => string The next step up in utility from system() and spawn(), the backquote method captures standard output from the subshell and as a bonus stores a Process::Status object in the thread-global $? variable.
  • 16. IO.popen cmd [, mode = "r"] => io IO.popen cmd [, mode = "r" [{ | io | block }] => obj Invokes a command shell in a subprocess and executes the specified commands, providing a [uni|bi]directional pipe which the parent process can use to communicate with the subprocess. Open3.popen3 cmd [{ |stdin, stdout, stderr| block }] Open3.popen3 cmd => array A wrapper for spawn() which provides access to the standard IO streams of the subshell along with a thread waiting on it.
  • 17. Kernel.fork [{ block }] => fixnum or nil Process.fork [{ block }] => fixnum or nil Ruby provides its own fork() implementation which can either take a block and run it in a subprocess, or can allow a more traditional split in execution paths. No IPC mechanism is provided beyond allowing the parent to wait on the child process and receive an error code. Kernel.exec [env ,] cmnd [, args] [, options] And as you’d expect it also allows access to the exec() family of system calls. This is a rare core library methods which doesn’t return a value for the simple reason that the existing program ceases to exist unless an error occurs, and that’s flagged with a SystemCallError exception. It’s common practice to terminate the program or retry exec() after a delay.
  • 18. zombie want brains a zombie is a subprocess which outlives its parent zombies are members of the system process group and are eventually terminated but until then they retain system resources and may not flush all of their IO buffers so get in the habit of flushing IO buffers regularly
  • 19. Process.wait2 => [ int, Process::status ] Prcess.waitpid2 pid, [ int = 0 ] => [ int, Process::status ] Prcess.waitall => [ [ int, Process::status ] *] Wait for a child process to exit. Wait2 watches all child processes and returns when any one process exits whilst waitpid2 waits for a specified child process, optionally masking for WNOHANG and WUNTRACED. Waitall waits on all child processes to exit and returns their statuses.
  • 20. the shell the glue that holds the system together
  • 21. standard shells provide an interactive environment on std[in|out|err] using an interpreted language for job control and file system manipulation the bourne shell is the lowest common denominator with a powerful POSIX-compatible syntax which is a pig to parse or maintain
  • 22. the Ruby way shell.rb ships with the standard library provides redirection, piping and standard commands tee, cat, echo, pwd, [push|pop]d enumerates files and directories with foreach as well as wrapping arbitrary system commands documented in The Ruby Way
  • 23. the unix kernel an overview with a Ruby twist
  • 24. basic services virtual memory process management hierarchical file system user permissions interprocess communication signals and interrupts execution environment
  • 25. file descriptors the kernel keeps a table of open files for each process an integer index is used to reference entries and is known as a file descriptor unix is liberal about what counts as a file and most descriptors are inherited by child processes caution file semantics can vary...
  • 26. beware the subtleties file descriptors are unique to a process so closing a descriptor only affects that process but the underlying descriptions are shared performing an lseek() changes the description and therefore will affect other processes with much hilarity ensuing...
  • 27. IO.sysopen path [, mode [, perm] => fixnum io.sysread int [, buffer] => string io.syswrite string => int io.sysseek offset, whence = SEEK_SET => int These methods make direct calls to the kernel to open and manipulate the contents of files, bypassing buffering. They shouldn’t be used with higher-level methods such as IO#read as unpredictable results may occur. Errors are raised as Exceptions in the Errno namespace.
  • 28. IO.new fd [, mode] [, opt] => io IO.for_fd fd [, mode] [, opt] => io Returns a new IO object (a stream) for the given IO object or integer file descriptor and mode string. See also IO#fileno and IO.for_fd. a = IO.new(2,"w") # '2' is the unix default for standard error $stderr.print "Hello" a.print " World" STDERR.print “!!” produces: Hello World!!
  • 29. require 'fcntl' filemode = Fcntl::O_CREAT | Fcntl::O_RDWR | Fcntl::O_APPEND descriptor = IO.sysopen “test.dat”, filemode file = IO.new descriptor file.syswrite “hello” file.sysseek 0 $stdout.puts file.sysread(10) produces: hello
  • 30. handling many files at once file access is much slower than memory access this causes threads and processes to block so usually IO is buffered by the kernel and non-blocking access methods are implemented however this is still ineffient when writing servers
  • 31. select rd_ary [, wrt_ary] [, err_ary] [, timeout] => array or nil Select is the standard low-level method for polling many IO streams at once and it’s a blocking call, hence the need for a timeout. For writing socket servers etc. this usually works reasonably well and Ruby’s implementation plays nicely with threads.
  • 32. kernel event queues allow the kernel to raise events for streams a process can then poll for events without blocking on BSD this is handled by kqueue on Linux by epoll and inotify epoll is much more efficient than inotify EventMachine uses these when available
  • 34. from the docs Kernel#syscall fixnum [, args...] => integer Calls the operating system function identified by fixnum, passing in the arguments, which must be either String objects, or Integer objects that ultimately fit within a native long. Up to nine parameters may be passed (14 on the Atari-ST). The function identified by fixnum is system dependent. On some Unix systems, the numbers may be obtained from a header file called syscall.h. syscall 4, 1, “hellon”, 6 # ‘4’ is write(2) on our box produces: hello
  • 35. finding your syscall codes MacOS X /usr/include/sys/syscall.h Linux /usr/include/asm/unistd_32.h /usr/include/asm/unistd_64.h
  • 36. a fragile approach the native syscall is a very primitive interface error codes file descriptors & pointer addresses modifiable buffers ruby syscall doesn’t support modifiable buffers but it does wrap errors as Errno exceptions
  • 37. IO.sysx the hard way On MacOS X file = syscall 5, “test.dat”, 1 # open O_WRONLY (fcntl.h) syscall 4, file, “some textn”, 10 # write syscall 3, file, “”, 5 # read syscall 6, file # close produces: Errno::EFAULT: Bad address should be Errno::EBADF
  • 38. complex parameters some kernel calls accept structured data types ruby represents these as String objects which can be prepared with Array#pack or Joel VanderWerf’s bit-struct library both approaches allow embedded nulls but on 1.9 remember to use 8-bit ASCII encoding
  • 39. currently broken On Ruby 1.8.7 or 1.9.1 (upto patch 129) syscall 4, 1, “hellon#{0.chr}goodbyen”, 15 produces: ArgumentError: string contains null byte from (irb):1:in `syscall' from (irb):1 from /usr/local/bin/irb19:12:in `<main>'
  • 40. Interprocess Communication IPC objects have descriptors like files but they don’t need to exist in the file system System V uses keys to identify IPC objects which are generated from paths using ftok() POSIX uses paths to identify IPC objects
  • 41. signals an abstraction for software interrupts SIGTERM and SIGKILL are the best known but *nixen provide a wide range of signals which can be used for cheap IPC ruby handles all of these via the Signal core class which allows you to write traps on individual signals
  • 42. sockets two varieties: domain sockets and network sockets Ruby provides a rich class hierarchy check out my other presentations for code examples some gotchas like DNS reverse lookup as default and Ruby doesn’t support kernel event queues but generally robust for ad hoc data streaming
  • 43. pipes pipes provide a pair of end-points for processes to talk an unnamed pipe connects two related processes a named pipe lives in the file system it has user permissions (restricted by umask) and persists independently of processes
  • 44. IO.pipe => read_file, write_file Ruby supports anonymous pipes, which can be used to communicate between a parent a child process, taking advantage of the fact that the file descriptors for the end-points will exist across a fork(). Good practice is for the parent process to close the reading end of the pipe whilst the child closes the writing end as soon as they return from fork() and the child should also close the reading end before it terminates to ensure buffered data is properly flushed.
  • 45. named pipes process 1 process 2 File.umask 0 File.umask 0 MKFIFO = 132 MKFIFO = 132 syscall MKFIFO, fifo_name, 0666 syscall MKFIFO, “client”, 0666 fd = IO.sysopen “server”, File::RDONLY fd = IO.sysopen "server", File::WRONLY server = File.new fd, "r" server = IO.new fd, "w" client_name = server.gets.chomp server.puts fifo_name puts "#{Time.now}: [#{client_name}]" server.puts "hello world!" fd = IO.sysopen client_name, File::WRONLY server.close client = IO.new fd, "w" fd = IO.sysopen “client”, File::RDONLY message = server.gets.chomp client = IO.new fd, "r" client.puts message.reverse puts client.gets client.close client.close server.close File.delete “client” File.delete “server”
  • 46. semaphores exist independently of processes provide blocking access allowing processes to be synchronised live in the file system and have a file descriptor usable from Ruby with syscall
  • 47. posix semaphores process 1 process 2 require ‘fcntl’ Open, Wait, TryWait, Post = 268, 271, 272, 273 Open, Wait, Post, Close = 268, 271, 273, 269 s = syscall Open, “/tmp/s” s = syscall Open, “/tmp/s”, Fcntl::O_CREAT, 1911 begin syscall Wait, s t = Time.now puts “locked at #{Time.now}” syscall TryWait, s sleep 50 puts “locked at #{t}” puts “posted at #{Time.now}” rescue Exception => e syscall Post, s puts “busy at #{t}” syscall Close, s syscall Wait, s puts “waited #{Time.now - t} seconds” end produces: produces: locked at Thu May 28 01:03:23 +0100 2009 busy at Thu May 28 01:03:36 +0100 2009 posted at Thu May 28 01:04:13 +0100 2009 waited 47.056508 seconds
  • 48. in the works shared memory message queues
  • 49. managed platform access memory buffers structs c runtime access
  • 51. in the standard library introduced in ruby 1.8 but poorly documented and lightly used provides access to dynamically loaded libraries supports managed C-style memory access and callback functions written in Ruby a viable alternative to the extension API
  • 52. memory management memory pointers encapsulated by DL::PtrData garbage collected uses free() or a custom deallocator handles realloc() automatically plays nicely with ruby strings and arrays [String|Array].to_ptr PtrData.struct! and PtrData.union!
  • 53. using native syscall require ‘dl’ libc = DL.dlopen(‘libc.dylib’) open = libc[‘syscall’, ‘IISI’] write = libc[‘syscall’, ‘IIISI’] read = libc[‘syscall’, ‘IIIsI’] close = libc[‘syscall’, ‘III’] produces: file = open.call 5, “test.dat”, 1 [3, [5, "test.dat", 1]] write.call 4, file[0], “textn”, 5 [5, [4, 3, "textn", 5]] close.call 6, file[0] [0, [6, 3]] file = open.call 5, “test.dat”, 0 [3, [5, "test.dat", 0]] buffer = DL.malloc(10) read.call(3, file[0], buffer, 10) [5, [3, 3, "textn", 10]] close.call 6, file[0] [0, [6, 3]]
  • 54. with a procedural slant require ‘dl’ file = open “test.dat”, 0x0209 CRT = DL.dlopen ‘libc.dylib’ write file, “textn” F = ‘syscall’ close file def open file, mode file = open “test.dat”, 0x0000 CRT[F, ‘IISI’].call(5, file, mode)[0] text = read file, 10 end close file def write fd, string, bytes = string.length CRT[F, ‘IIISI’].call(4, fd, string, bytes)[0] end def read fd, bytes = 1 buffer = DL.malloc(bytes) CRT[F, ‘IIIsI’].call(3, fd, buffer, bytes)[1][2] end def close fd CRT[F, ‘III’].call(6, fd)[0] end
  • 56. the bluffer’s reading list http://slides.games-with-brains.net http://www.jbrowse.com/text/rdl_en.html http://www.kegel.com/c10k.html http://www.ecst.csuchico.edu/~beej/guide/ipc/ http://beej.us/guide/bgnet/ http://wiki.netbsd.se/kqueue_tutorial
  • 57. QEMFD? find out at Lone Star Ruby Conf 2009