Commit cb4dac8a authored by San Mehat's avatar San Mehat
Browse files

vold: Remove autorun.inf at mount/unmount time if it exists


Change-Id: Ia57da8ee177453a601a23d965c2b4f16b6de46e5
Signed-off-by: default avatarSan Mehat <san@google.com>
parent 57df7bf3
......@@ -112,6 +112,25 @@ Volume::~Volume() {
free(mMountpoint);
}
void Volume::protectFromAutorunStupidity() {
char filename[255];
snprintf(filename, sizeof(filename), "%s/autorun.inf", SEC_STGDIR);
if (!access(filename, F_OK)) {
LOGW("Volume contains an autorun.inf! - removing");
/*
* Ensure the filename is all lower-case so
* the process killer can find the inode.
* Probably being paranoid here but meh.
*/
rename(filename, filename);
Process::killProcessesWithOpenFiles(filename, 2);
if (unlink(filename)) {
LOGE("Failed to remove %s (%s)", filename, strerror(errno));
}
}
}
void Volume::setDebug(bool enable) {
mDebug = enable;
}
......@@ -306,6 +325,8 @@ int Volume::mountVol() {
LOGI("Device %s, target %s mounted @ /mnt/secure/staging", devicePath, getMountpoint());
protectFromAutorunStupidity();
if (createBindMounts()) {
LOGE("Failed to create bindmounts (%s)", strerror(errno));
umount("/mnt/secure/staging");
......@@ -487,6 +508,8 @@ int Volume::unmountVol(bool force) {
return -1;
}
protectFromAutorunStupidity();
/*
* Unmount the tmpfs which was obscuring the asec image directory
* from non root users
......
......@@ -87,6 +87,7 @@ private:
int createBindMounts();
int doUnmount(const char *path, bool force);
int doMoveMount(const char *src, const char *dst, bool force);
void protectFromAutorunStupidity();
};
typedef android::List<Volume *> VolumeCollection;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment