Table of parts: https://docs.google.com/document/d/1IIOkivkS0lV9QIL16b_OjT480BxZHQfKswvvS-CVZlw/view
Building existing programs and libraries
Example: /home/vi/progs/dropbear
Example: /home/vi/progs/dropbear
Example: /home/vi/progs/dropbear/prefix
Example: /usr/local
topics:
Download the source code of "htop" program and build it. Alternative: http://neil.brown.name/wiggle/
$ apt-file search libncursesw
lib32ncursesw5: /lib32/libncursesw.so.5
lib32ncursesw5: /lib32/libncursesw.so.5.9
lib32ncursesw5-dev: /usr/lib32/libncursesw.a
lib32ncursesw5-dev: /usr/lib32/libncursesw.so
libncursesw5: /lib/x86_64-linux-gnu/libncursesw.so.5
libncursesw5: /lib/x86_64-linux-gnu/libncursesw.so.5.9
libncursesw5: /usr/share/doc/libncursesw5
libncursesw5-dbg: /usr/lib/debug/libncursesw.so.5
libncursesw5-dbg: /usr/lib/debug/libncursesw.so.5.9
libncursesw5-dbg: /usr/share/doc/libncursesw5-dbg
libncursesw5-dev: /usr/lib/x86_64-linux-gnu/libncursesw.a
libncursesw5-dev: /usr/lib/x86_64-linux-gnu/libncursesw.so
libncursesw5-dev: /usr/share/doc/libncursesw5-dev
libx32ncursesw5: /usr/libx32/libncursesw.so.5
libx32ncursesw5: /usr/libx32/libncursesw.so.5.9
libx32ncursesw5-dev: /usr/libx32/libncursesw.a
libx32ncursesw5-dev: /usr/libx32/libncursesw.so
Install the built htop program into /usr/local
Create a Debian package for your htop
checkinstall --install=no --fstrans
GCC terms:
Simplified "pseudocode session":
x86$ # Let's compile a compiler.
x86$ ./configure --build=x86 --host=arm --target=mips
x86$ make
Compilation of a compiler successful.
x86$ # OK, now we have a compiler. Let's run it…
x86$ ./the_compiler hello.c -o hello
Error: Can't run ./the_compiler. It's for ARM, not for X86.
x86$ # So copy it to ARM.
x86$ scp the_compiler arm:
x86$ ssh arm
arm$ ./the_compiler hello.c -o hello
Compilation successful
arm$ ./hello
Error: Can't run ./hello. It's for MIPS, not for ARM.
arm$ scp hello mips:./ && ssh misp
misp$ ./hello
Hello, world.
Build dropbear from source code.
Соберите из исходного кода dropbear.
Configuration and using of SSH
Start dropbear instance you have configured and connect to it from localhost;
TODO: insert dropbrear launch and key generation commands here
Linux file system, part 2
$ dd if=/dev/zero bs=1M count=64 of=qqq
# losetup /dev/loop3 qqq
# mkfs.ext4 /dev/loop3
# mount -t ext4 /dev/loop3 /home/user/somedir
# echo qqq > /home/user/somedir/somefile
…
# umount /home/user/somedir
# losetup -d /dev/loop3
Execute commands from this chapter.
Выполните команды из главы.
Exercise 2
Get inode and device number for the following files:
Узнайте номер устройства и inode для задействованных файлов:
Try to make chroot'table system with some commands inside:
Boot process of a Linux system
Enter GRUB menu. Inspect the kernel parameters.
Зайдите в меню GRUB. Посмотрите на параметры ядра.
Try booting the system from GRUB console. Try to use minimal necessary number of parameters.
Запустите систему из консоли GRUB. Постарайтесь использовать минимум параметров.
Try booting the system, overriding init to /bin/bash. Use "exec /sbin/init" to continue booting.
Попробуйте запустить систему, используя /bin/bash вместо init'а. Используйте "exec /sbin/init" чтобы продолжить загрузку.
Open source licenses
Primary glossary:
(note: I'm not a lawyer and this can't be a real legal advice)
Pub domain CC0 | Permissive MIT / BSD | LGPL GPL with linking exception | GPL | |
Can I just use it in a distributable project without asking anyone and without distributing any source code? | Yes | Yes* | Only if unchanged | No |
Can I use it in a distributable project distributing changes to the library in question and making sure the library can be replaced by end user? | Yes | Yes* | Yes | No |
Can I use it in Open Source project? | Yes | Yes* | Yes | Yes* |
Can I remove information about original author and write myself as an author instead? | No | No | No | No |
Can I use it in my program that I don't distribute at all, just for myself? | Yes | Yes | Yes | Yes |
Can I learn from a library and make my own employing similar algorithm, without directly copying or linking any code? | Yes | Yes | Yes | Yes |
Can I link my nonfree project statically to it? | Yes | Yes* | Probably no | No |
Can I check authenticity of the binary or source library in my project and refuse to use user-changed versions? | Yes | Yes* | "No" by the spirit, "It depends" IRL | No |
For example, there is API which both GPL and permissive library implements. User can replace the permissive library with GPL one. What if instructions of such replacement are published to user forum? What if program can discover all libraries that implement this API? What if program downloads the library from internet and installs it automatically?
Exercise 1
Can I use libmatroska in my open source project? Proprietary project?
Exercise 2
Can you use libpng in your proprietary project? To which column in the table above does belong its license?
Exercise 3 (trickier)
$ /opt/ffmpeg/ffmpeg2015 -version
ffmpeg version n2.5.3 Copyright (c) 2000-2015 the FFmpeg developers built on Feb 10 2015 03:15:42 with gcc 4.7 (Debian 4.7.2-5) configuration: --enable-static --disable-shared --enable-gpl --enable-version3 --enable-nonfree --disable-libass --enable-frei0r --enable-libaacplus --enable-libfaac --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-libopencv --enable-libopenjpeg --enable-libopus --disable-librtmp --disable-libschroedinger --enable-libspeex --enable-libtheora --enable-libtwolame --disable-libv4l2 --enable-libvidstab --disable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxvid --disable-x11grab --disable-ffplay --disable-devices --disable-vdpau --enable-libx265
Community and Open source
Theory
Debugging
Text handling
controlling terminal, shortcuts, raw terminals, stty