Git Product home page Git Product logo

liberate-applefileserver's Introduction

Liberate AppleFileServer

The Epic Disclaimer!

The included code works just well enough for my purposes and hasn't been tested at all outside my set-up. Basically, if you're going to play with this you must (a) know exactly what it's doing and why it's doing it, and (b) have backups of any data it goes anywhere near. Whilst I've not experienced any negative side-effects (so far) this doesn't mean you won't and I'm not accepting any liability for anything that may go wrong.

The background

For some reason, Apple have neutered the AppleFileServer in Lion preventing non-HFS external disk filesystems from being shared over AFP. This is exceptionally frustrating and has scuppered my plans for a ZFS based file-server backed by a pool of USB and FireWire disks. The common suggestion of copying the AppleFileServer binary from Snow Leopard into place left a bad taste in my mouth, so I wondered if there was a better way...

The hook

This library gets injected (using the DYLD_INJECT_LIBRARY environment variable) into the AppleFileServer process by a tweak to the launchd configuration. Once in place, it hooks the FSGetVolumeInfo API call and fudges the return values to make all your volumes look like they are HFS+ volumes. Specifically, the filesystemID field is forced to 0 and the signature set to a specific constant.

This is the result of numerous hours poking around at the various candidate API function calls that provide filesystem information, from inside the AppleFileSystem daemon with GDB, a test hook library and a small test ZFS pool.

I've been using the excellent MacZFS package. Well worth playing around with.

Installation

You'll need to compile a .dylib shared library from the c-file, which you can do (if you have the Apple Developer Tools installed) by executing:

gcc -dynamiclib -Wall -undefined dynamic_lookup -o liberate-fileserver.dylib liberate.m

This will kick out a shared library file liberate-fileserver.dylib that must be copied into place, pop it into /usr/local/lib for now.

sudo mkdir -p /usr/local/lib
sudo cp liberate-fileserver.dylib /usr/local/lib/

Now inject this library into the AppleFileServer daemon by adding the liberate fileserver library to the dynamic loading path of apples fileserver:

sudo defaults write /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist  EnvironmentVariables -dict DYLD_INSERT_LIBRARIES /usr/local/lib/liberate-fileserver.dylib 

Once you've done this, restart the File Sharing server from within System Preferences, share your filesystem and (hopefully) it should be available to your networked machines.

Huzzah!

liberate-applefileserver's People

Contributors

jollyjinx avatar joshado avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

liberate-applefileserver's Issues

Stopped working with 10.8.1

I'm not sure why, but injecting this library causes the file server to fail to startup. You cannot connect to the server and trying to change the Sharing System Preference pane is very prone to strange hangs which take about a minute to resolve.
This patch was working with 10.8.0! ugh

I tried changing it around to do significantly more validation on the input parameters and limited the changes to just the volumes I wanted to share, but it still fails the same way.

The volume I'm trying to share is a MacZFS volume. Any tips on things to look for (breakpoints, etc)? I am a software developer.

FSGetVolumeInfo Deprecated in 10.8 ...

I wish I could offer advice on how to fix. It seems to work on Mountain Lion but not sure for how long?

liberate.m: In function ‘hooked_FSGetVolumeInfo’:
liberate.m:17: warning: ‘FSGetVolumeInfo’ is deprecated (declared at     
/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Files.h:3931)
liberate.m: At top level:
liberate.m:27: warning: ‘FSGetVolumeInfo’ is deprecated (declared at  
/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Files.h:3931)

Cite: https://developer.apple.com/library/mac/#documentation/Carbon/Reference/File_Manager/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/c/func/FSGetVolumeInfo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.