Linux shell for iOS

Overview

iSH

Build Status goto counter fuck counter

A project to get a Linux shell running on iOS, using usermode x86 emulation and syscall translation.

For the current status of the project, check the issues tab, and the commit logs.

Hacking

This project has a git submodule, make sure to clone with --recurse-submodules or run git submodule update --init after cloning.

You'll need these things to build the project:

  • Python 3
    • Meson (pip3 install meson)
  • Ninja
  • Clang and LLD (on mac, brew install llvm, on linux, sudo apt install clang lld or sudo pacman -S clang lld or whatever)
  • sqlite3 (this is so common it may already be installed on linux and is definitely already installed on mac. if not, do something like sudo apt install libsqlite3-dev)
  • libarchive (brew install libarchive, sudo port install libarchive, sudo apt install libarchive-dev) TODO: bundle this dependency

Build for iOS

Open the project in Xcode, open iSH.xcconfig, and change ROOT_BUNDLE_IDENTIFIER to something unique. You'll also need to update the development team ID in the project (not target!) build settings. Then click Run. There are scripts that should do everything else automatically. If you run into any problems, open an issue and I'll try to help.

Build command line tool for testing

To set up your environment, cd to the project and run meson build to create a build directory in build. Then cd to the build directory and run ninja.

To set up a self-contained Alpine linux filesystem, download the Alpine minirootfs tarball for i386 from the Alpine website and run ./tools/fakefsify, with the minirootfs tarball as the first argument and the name of the output directory as the second argument. Then you can run things inside the Alpine filesystem with ./ish -f alpine /bin/login -f root, assuming the output directory is called alpine. If tools/fakefsify doesn't exist for you in your build directory, that might be because it couldn't find libarchive on your system (see above for ways to install it.)

You can replace ish with tools/ptraceomatic to run the program in a real process and single step and compare the registers at each step. I use it for debugging. Requires 64-bit Linux 4.11 or later.

Logging

iSH has several logging channels which can be enabled at build time. By default, all of them are disabled. To enable them:

  • In Xcode: Set the ISH_LOG setting in iSH.xcconfig to a space-separated list of log channels.
  • With Meson (command line tool for testing): Run meson configure -Dlog="<space-separated list of log channels>".

Available channels:

  • strace: The most useful channel, logs the parameters and return value of almost every system call.
  • instr: Logs every instruction executed by the emulator. This slows things down a lot.
  • verbose: Debug logs that don't fit into another category.
  • Grep for DEFAULT_CHANNEL to see if more log channels have been added since this list was updated.

A note on the JIT

Possibly the most interesting thing I wrote as part of iSH is the JIT. It's not actually a JIT since it doesn't target machine code. Instead it generates an array of pointers to functions called gadgets, and each gadget ends with a tailcall to the next function; like the threaded code technique used by some Forth interpreters. The result is a speedup of roughly 3-5x compared to pure emulation.

Unfortunately, I made the decision to write nearly all of the gadgets in assembly language. This was probably a good decision with regards to performance (though I'll never know for sure), but a horrible decision with regards to readability, maintainability, and my sanity. The amount of bullshit I've had to put up with from the compiler/assembler/linker is insane. It's like there's a demon in there that makes sure my code is sufficiently deformed, and if not, makes up stupid reasons why it shouldn't compile. In order to stay sane while writing this code, I've had to ignore best practices in code structure and naming. You'll find macros and variables with such descriptive names as ss and s and a. Assembler macros nested beyond belief. And to top it off, there are almost no comments.

So a warning: Long-term exposure to this code may cause loss of sanity, nightmares about GAS macros and linker errors, or any number of other debilitating side effects. This code is known to the State of California to cause cancer, birth defects, and reproductive harm.

Comments
  • Selecting text will copy it into the pasteboard

    Selecting text will copy it into the pasteboard

    In the latest TestFlight build 35, when I just long press text to select it on iSH, it will be copied into the pasteboard even if I don’t tap the “Copy” item.

    How to reproduce it: https://youtu.be/OoDOArAkhSg

    1. Select text
    2. Tap “Paste” item

    I reproduced the issue on

    • 3rd generation 12.9” iPad Pro with iOS 12.1.1
    • iPad Air 2 with iOS 12.1
    • iPhone XS with iOS 12.1.1

    Related to #25

    opened by kkk669 31
  • wget issue

    wget issue

    a random bad bug (at least with commit fd48ae6, f802873, maybe also with c846847, will try with old commit when I have some time)

    sometime wget issue with "wget: read error: Invalid argument" and the same url with curl work fine. seem to be related to network.

    you can try with following url: https://dl.i4th.me/a, this one should retrieve a 41KB file https://dl.i4th.me/b, this one should retrieve a 5KB file sometime only wget for b work, sometime both work, sometime none work no failure at this time with curl

    no repro 
    opened by francoisvignon 25
  • Oh-my-zsh compatibility

    Oh-my-zsh compatibility

    I'm experiencing OMZ compatibility issue on my 2018 iPad Pro with iPadOS 14.5 beta, which doesn’t happen on my iPhone with iOS 14.4.2.

    Situation: The prompt label doesn’t display, no matter it’s local or remote. Syntax highlighting is also buggy. zsh itself and other shells seem all fine.

    30F64E28-E0AC-4FEC-BBD7-030570F389C8

    unconfirmed 
    opened by stevapple 22
  • I/O ERROR during apk install

    I/O ERROR during apk install

    We're trying to collect diagnostics for an Apple bug report. If this happens to you, please immediately capture a sysdiagnose (press both volume buttons and the power button simultaneously for a few seconds) and send this to me, along with the approximate date and time the issue occurred and the output of dmesg. Thanks! [email protected]


    i get following error . Any idea ?

    D6AF50D0-52A5-4951-8B21-FFEEB629DC68

    opened by F3000 22
  • Race between execve and proc_pid_cmdline_show

    Race between execve and proc_pid_cmdline_show

    See attached image for some context. This is the script I'm running that causes the crash...

    #!/bin/bash tmux new-session -s "My iPad" -d tmux split-window -h tmux split-window -v tmux -2 attach-session -d

    Note that I can manually create the same layout after running tmux manually.

    Screen Shot 2020-12-06 at 4 53 01 PM
    opened by emkey1 22
  • Friendly-shell 'fish' cannot process a local example, but unknown or corrupted style, of file linking/also originated by unknown tool, which ash/bash, et.al. could use uninhibited.

    Friendly-shell 'fish' cannot process a local example, but unknown or corrupted style, of file linking/also originated by unknown tool, which ash/bash, et.al. could use uninhibited.

    fish seems to work now.

    Originally posted by @tbodt in https://github.com/ish-app/ish/issues/122#issuecomment-449228241

    fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86/APKINDEX.tar.gz (1/3) Installing bc (1.07.1-r1) (2/3) Installing libpcre2-32 (10.35-r0) (3/3) Installing fish (3.1.2-r0) Executing fish-3.1.2-r0.post-install Executing busybox-1.31.1-r19.trigger 3 errors; 3025 MiB in 687 packages iPhone0 user [email protected] 26_ 4:00PM~(/root)-zsh:which fish /usr/bin/fish iPhone0 user [email protected] 26_ 4:00PM~(/root)-zsh:ldd /usr/bin/fish /lib/ld-musl-i386.so.1 (0xf7f6e000) libncursesw.so.6 => /usr/lib/libncursesw.so.6 (0xf7d99000) libpcre2-32.so.0 => /usr/lib/libpcre2-32.so.0 (0xf7d09000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xf7b74000) libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0xf7b5b000) libc.musl-x86.so.1 => /lib/ld-musl-i386.so.1 (0xf7f6e000) iPhone0 user [email protected] 26_ 4:01PM~(/root)-zsh:

    iPhone0 user [email protected] 26_ 4:06PM~(/root)-zsh:history 1 apk search go 2 apk list go 3 go --help 4 go packages 5 go list 6 go env 7 go get -u github.com/ramya-rao-a/go-outline 8 dmesg 9 apk list fish 10 apk add fish 11 which fish 12 ldd /usr/bin/fish 13 fish iPhone0 user [email protected] 26_ 4:06PM~(/root)-zsh:fish Welcome to fish, the friendly interactive shell Type help for instructions on how to use fish [email protected] ~# history Failed to execute process '/usr/bin/less'. Reason: exec: unknown error (errno was 13) [email protected] ~ [125]# dmesg [ 0.000000] 496 stub syscall 375

    [email protected] ~ [1]# ls -la /usr/bin/less -rw-rw-rw- 1 root root 12 Jul 20 00:59 /usr/bin/less [email protected] ~# chmod +x /usr/bin/less [email protected] ~# history Failed to execute process '/usr/bin/less'. Reason: exec: unknown error (errno was 8) The file '/usr/bin/less' is marked as an executable but could not be run by the operating system.

    unconfirmed 
    opened by 62f 21
  • kerberos commands return “Bad file descriptor”

    kerberos commands return “Bad file descriptor”

    HI - I’m really looking forward to use ish to access computing resources from my iPad. We use kerberos for security. I did

    apk add krb5
    

    and copied my krb5.conf file to /etc/krb5.conf.

    I get a Kerberos ticket with kinit. The communication with our kerberos server seems to work, but it ends with an error...

    ipad-132427:~# kinit <removed>
    Password for <removed> 
    kinit: Failed to store credentials: Bad file descriptor (filename: /tmp/krb5cc_0) while getting initial credentials
    

    There’s an option to kinit that saves credentials to any file, and when I do a file in /root it fails the same way.

    Furthermore, the klist command, which tells me what tickets I have (maybe none) also fails with a similar Bad file descriptor error.

    I imagine the kerberos executables were built in some incompatible way. Any ideas? Let me know how I can help! Thanks, Adam

    opened by lyon-fnal 21
  • Support ngrok error illegal instruction

    Support ngrok error illegal instruction

    opened by professorUnknown 20
  • Feature Request: Allow the Ish app to run in the background.

    Feature Request: Allow the Ish app to run in the background.

    The Ish app should be allowed to run in the background if you leave the app. Sometimes I have to leave the app, and then the in-app processes would stop so allowing the app to run in the background would be great.

    opened by VincentCCandela 20
  • Inform 7 (interactive fiction)

    Inform 7 (interactive fiction)

    Can someone tell me if Inform 7 works on iSH? I tried to install it with script but obviously it didn't work. I manually unzipped the right files, but when I try to compile a sample file, it doesn't work.

    http://inform7.com/download/content/6M62/I7_6M62_Linux_all.tar.gz

    opened by ecstaticax 19
  • network not use

    network not use

    liuende:~# cat /etc/resolv.conf                        nameserver 192.168.1.1                                 liuende:~# ping 192.168.1.1                            PING 192.168.1.1 (192.168.1.1): 56 data bytes          ping: sendto: Host is unreachable                      liuende:~# apk add openssh                             fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x 86/APKINDEX.tar.gz                                     ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.8/main:  temporary error (try again later)                     WARNING: Ignoring APKINDEX.adfa7ceb.tar.gz: No such fi le or directory                                        fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/commun ity/x86/APKINDEX.tar.gz                                ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.8/commu nity: temporary error (try again later)                WARNING: Ignoring APKINDEX.efaa1f73.tar.gz: No such fi le or directory                                        ERROR: unsatisfiable constraints:                        openssh (missing):                                       required by: world[openssh]  

    opened by DHCMediWay 18
  • Sixel support

    Sixel support

    How about support for sixels?

    There's an xterm.js addon that supports sixels here: https://github.com/jerch/xterm-addon-image

    I've used it for the web and it worked nicely. No idea if it'd work with iSH but it would be very cool if it did.

    Related to #381, which was closed because there wasn't a sixel solution at the time.

    unconfirmed 
    opened by guregu 0
  • Playing sound with sox not working

    Playing sound with sox not working

    Sox installed with

    apk add sox
    

    How ever, play audio.mp3 reports error:

    ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
    ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
    ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
    ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
    ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5599:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
    ERROR: Failed to load plugin /usr/lib/ao/plugins-4/libalsa.so => dlopen() failed
    play FAIL ao: Could not find a default ao driver
    play FAIL sox: Sorry, there is no default audio device configured
    
    unconfirmed 
    opened by phuongnd08 0
  • OpenCV build doesn't support current CPU/HW configuration

    OpenCV build doesn't support current CPU/HW configuration

    iPad-Pro-105-inch:~# python3 Python 3.10.8 (main, Nov 10 2022, 12:59:17) [GCC 11.2.1 20220219] on linux Type "help", "copyright", "credits" or "license" for more information.

    import cv2


    • FATAL ERROR: *
    • This OpenCV build doesn't support current CPU/HW configuration *
    •                                                            *
      
    • Use OPENCV_DUMP_CONFIG=1 environment variable for details *

    Required baseline features: ID= 2 (SSE) - NOT AVAILABLE ID= 3 (SSE2) - NOT AVAILABLE terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(4.5.5) /home/buildozer/aports/community/opencv/src/opencv-4.5.5/modules/core/src/system.cpp:677: error: (-215:Assertion failed) Missing support for required CPU baseline features. Check OpenCV build configuration and required CPU/HW setup. in function 'initialize'

    Aborted iPad-Pro-105-inch:~# cpuinfo Python Version: 3.10.8.final.0 (32 bit) Cpuinfo Version: 7.0.0 Vendor ID Raw: Hardware Raw: Brand Raw: Hz Advertised Friendly: Hz Actual Friendly: Hz Advertised: Hz Actual: Arch: X86_32 Bits: 32 Count: 3 Arch String Raw: i686 L1 Data Cache Size: L1 Instruction Cache Size: L2 Cache Size: L2 Cache Line Size: L2 Cache Associativity: L3 Cache Size: Stepping: Model: Family: Processor Type: Flags: iPad-Pro-105-inch:~# cat /etc/os-release iPad-Pro-105-inch:~# cat /etc/os-release NAME="Alpine Linux" ID=alpine VERSION_ID=3.14.3 PRETTY_NAME="Alpine Linux v3.14" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://bugs.alpinelinux.org/" iPad-Pro-105-inch:~# pip list Package Version


    appdirs 1.4.4 certifi 2021.10.8 contextlib2 21.6.0 cycler 0.10.0 Cython 0.29.24 fonttools 4.33.0 fs 2.4.16 kiwisolver 1.2.0 lxml 4.8.0 matplotlib 3.5.2 more-itertools 8.13.0 olefile 0.46 ordered-set 4.0.2 packaging 21.3 pep517 0.12.0 Pillow 9.1.1 pip 22.1.1 py-cpuinfo 7.0.0 pycairo 1.20.1 pyparsing 2.4.7 python-dateutil 2.8.2 pytz 2022.6 retrying 1.3.3 setuptools 59.4.0 six 1.16.0 tomli 2.0.1 iPad-Pro-105-inch:~#

    unconfirmed 
    opened by AsianUncleSam 1
  • Data race in fakefs_evict_inode and fakefs_readpage (iSH+Linux)

    Data race in fakefs_evict_inode and fakefs_readpage (iSH+Linux)

    I can dig into this later (time permitting) but for now just a screen grab:

    image

    Reproduce by building a project of your choosing (within iSH) with make --jobs=X set to anything greater than 1

    unconfirmed 
    opened by jason-conway 1
  • Paste function has been malfunctioning since iPadOS 16 update

    Paste function has been malfunctioning since iPadOS 16 update

    Environment : iPadOS 16.1 Since the update to iPadOS 16, iSh Shell does not function properly when pasting large amounts of text. This problem can be easily detected when using text editor such as vi or vim. If I paste a large amount of text (more than a 50-70 lines), only some of it is pasted. Because of this, the texts at the bottom are not pasted at all. Both using keyboard shortcuts and pressing the Clipboard button in the lower left corner of the app cause this problem.

    unconfirmed 
    opened by aweolakdlf 0
Releases(builds/434)
Owner
iSH
Linux emulator for iOS
iSH
Linux shell for iOS

iSH A project to get a Linux shell running on iOS, using usermode x86 emulation and syscall translation. For the current status of the project, check

iSH 13k Nov 25, 2022
A shell for unix and linux systems

Snash A shell for unix/linux A shell for unix and linux systems. This is still a work in progress and ALOT has yet to be implemented. Snash stands for

Reinhold 6 Nov 26, 2022
Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2

Filament Filament is a real-time physically based rendering engine for Android, iOS, Linux, macOS, Windows, and WebGL. It is designed to be as small a

Google 14.9k Nov 25, 2022
Oxygine is C++ engine and framework for 2D games on iOS, Android, Windows, Linux and Mac

BUILD AND RUN See oxygine-framework/readme/ folder. It has instructions on how to build and run oxygine on different platforms. Wiki available at http

Oxygine 735 Nov 24, 2022
Sega Master System / Game Gear / SG-1000 emulator for iOS, macOS, Raspberry Pi, Windows, Linux, BSD and RetroArch.

Gearsystem is a very accurate, cross-platform Sega Master System / Game Gear / SG-1000 emulator written in C++ that runs on Windows, macOS, Linux, BSD, iOS, Raspberry Pi and RetroArch.

Ignacio Sanchez Gines 180 Nov 21, 2022
Hobbyist Operating System targeting x86_64 systems. Includes userspace, Virtual File System, An InitFS (tarfs), Lua port, easy porting, a decent LibC and LibM, and a shell that supports: piping, file redirection, and more.

SynnixOS Epic Hobby OS targeting x86_64 CPUs, it includes some hacked together functionality for most essential OSs although, with interactivity via Q

RaidTheWeb 42 Oct 28, 2022
A custom macOS statusbar with shell plugin, interaction and graph support

SketchyBar This is a rewrite of the spacebar project, which itself is a rewrite of the statusbar code from yabai. Features: As many widgets as you lik

Felix Kratz 1.3k Nov 25, 2022
The simple UEFI application to create a Windows Platform Binary Table (WPBT) from the UEFI shell.

WPBT Builder This is a simple UEFI application to create a Windows Platform Binary Table (WPBT) from the UEFI shell. Motivation WPBT is one of the Adv

Satoshi Tanda 70 Nov 23, 2022
Make BAD USB to Reverse Shell with Arduino Digispark (recommended with attiny85)

Make BAD USB to Reverse Shell with Arduino Digispark (recommended with attiny85) Cara Pakai Pastikan Anda telah menginstal Driver Digispark dan mengon

Edo 3 Apr 17, 2022
Shell program written in C to implement various system calls, with support of executing commands, output redirection and signals.

Use ./shell command to start the shell. $<space>path/executable to run the executable(please specify the path without beginning it with "/"). Eg. type

Ayuj Panchal 1 Nov 15, 2021
Creates a virtual disk in memory and provides the user a shell to interact with it

Tiny-File-System Creates a virtual disk in memory and provides the user a shell to interact with it Known bugs with Export missing chars at the end of

Alex Fuller 2 Oct 7, 2022
Wayfire plugin for handling touchpad gestures globally in a layer-shell surface

wf-globalgestures Global touchpad gestures plugin for Wayfire: implements a special protocol (also in this repo) that lets clients request that a part

null 3 Oct 3, 2022
FogCube shell written in C++

IDK This is just a program that lexing and parsering an input from the prompt. What this program actually? Well, I dont know, I make this program just

null 1 Dec 28, 2021
This project simulates the functionality of the Unix Bash shell.

Minishell This project simulates the functionality of the unix Bash shell. Description The project aim was to recreate the functionality of the unix B

Andreas Gebert 0 Jan 6, 2022
Simple mini-shell coded in C Language

Mini Shell Simple mini-shell coded in C Language, i had a lot of informations and experiences on Linux processes and some low level stuff while coding

Sc1r3Cr0w 4 Jun 16, 2022
Ccd - Edge first cd replacement tool for Windows cmd shell.

Cursorial CD Cursorial CD, or ccd for short, is a cd replacement for Window's cmd shell. Unlike cd, it operates on an edge first search, so you can qu

Scott Seligman 5 Feb 2, 2022
Minishell - This project aims to recreate most of the bash shell.

minishell Contents Info How to use Clone repo and submodules Linux dependencies MAC dependencies Compile and execute Install Features Built-in command

izenynn 2 Jun 9, 2022
Microshell - a lightweight pure C implementation of shell emulator dedicated for embedded bare-metal systems.

MicroShell Lightweight pure C implementation of virtual shell, compatible with VT100 terminal. Support root tree, run-time mounting paths, global comm

Marcin Borowicz 96 Nov 26, 2022
An extension manager for browsing and installing GNOME Shell Extensions.

Extension Manager A native tool for browsing, installing, and managing GNOME Shell Extensions. Written with GTK 4 and libadwaita. Features The tool su

Matt Jakeman 549 Nov 29, 2022