Is it possible to intercept calls to unlink and redirect files to /trash?
up vote
1
down vote
favorite
I would like to know if there is a way to create a trash by intercepting calls to unlink. Theoretically files would be timestamped and deleted after set time period.
trash
New contributor
add a comment |
up vote
1
down vote
favorite
I would like to know if there is a way to create a trash by intercepting calls to unlink. Theoretically files would be timestamped and deleted after set time period.
trash
New contributor
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I would like to know if there is a way to create a trash by intercepting calls to unlink. Theoretically files would be timestamped and deleted after set time period.
trash
New contributor
I would like to know if there is a way to create a trash by intercepting calls to unlink. Theoretically files would be timestamped and deleted after set time period.
trash
trash
New contributor
New contributor
edited yesterday
Rui F Ribeiro
38.2k1475123
38.2k1475123
New contributor
asked yesterday
Stuperfied
63
63
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Yes, there is. The general mechanism for this type of thing (overriding a standard function) is called LD_PRELOAD. The general idea is pretty simple, when loading libraries into memory for a program, whichever one is the first to define a given symbol name defines what that symbol does. So, LD_PRELOAD lets you tell the dynamic linker to load specific libraries before all others (including libc), meaning that they can override specific functions from libraries which would be loaded later.
Examples of widely used projects that make use of LD_PRELOAD include:
jemalloc Can be pre-loaded to let you use the jemalloc memory allocator with programs that don't explicitly use it themselves.
datefudge Lets you fake the system time and date.
libeatmydata Overridessync()
and related calls to do nothing, improving performance of some applications at the cost of data safety.
dante Includes a command that uses LD_PRELOAD to enable SOCKS protocol usage for applications which don't natively support it.
There's also a library that does exactly what you're asking about called libtrash
. The official web-page can be found here. I'm not sure if it works or not as I've never used it myself, but there was a recent release of a new version so it looks like the author is at least still maintaining it.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Yes, there is. The general mechanism for this type of thing (overriding a standard function) is called LD_PRELOAD. The general idea is pretty simple, when loading libraries into memory for a program, whichever one is the first to define a given symbol name defines what that symbol does. So, LD_PRELOAD lets you tell the dynamic linker to load specific libraries before all others (including libc), meaning that they can override specific functions from libraries which would be loaded later.
Examples of widely used projects that make use of LD_PRELOAD include:
jemalloc Can be pre-loaded to let you use the jemalloc memory allocator with programs that don't explicitly use it themselves.
datefudge Lets you fake the system time and date.
libeatmydata Overridessync()
and related calls to do nothing, improving performance of some applications at the cost of data safety.
dante Includes a command that uses LD_PRELOAD to enable SOCKS protocol usage for applications which don't natively support it.
There's also a library that does exactly what you're asking about called libtrash
. The official web-page can be found here. I'm not sure if it works or not as I've never used it myself, but there was a recent release of a new version so it looks like the author is at least still maintaining it.
add a comment |
up vote
1
down vote
Yes, there is. The general mechanism for this type of thing (overriding a standard function) is called LD_PRELOAD. The general idea is pretty simple, when loading libraries into memory for a program, whichever one is the first to define a given symbol name defines what that symbol does. So, LD_PRELOAD lets you tell the dynamic linker to load specific libraries before all others (including libc), meaning that they can override specific functions from libraries which would be loaded later.
Examples of widely used projects that make use of LD_PRELOAD include:
jemalloc Can be pre-loaded to let you use the jemalloc memory allocator with programs that don't explicitly use it themselves.
datefudge Lets you fake the system time and date.
libeatmydata Overridessync()
and related calls to do nothing, improving performance of some applications at the cost of data safety.
dante Includes a command that uses LD_PRELOAD to enable SOCKS protocol usage for applications which don't natively support it.
There's also a library that does exactly what you're asking about called libtrash
. The official web-page can be found here. I'm not sure if it works or not as I've never used it myself, but there was a recent release of a new version so it looks like the author is at least still maintaining it.
add a comment |
up vote
1
down vote
up vote
1
down vote
Yes, there is. The general mechanism for this type of thing (overriding a standard function) is called LD_PRELOAD. The general idea is pretty simple, when loading libraries into memory for a program, whichever one is the first to define a given symbol name defines what that symbol does. So, LD_PRELOAD lets you tell the dynamic linker to load specific libraries before all others (including libc), meaning that they can override specific functions from libraries which would be loaded later.
Examples of widely used projects that make use of LD_PRELOAD include:
jemalloc Can be pre-loaded to let you use the jemalloc memory allocator with programs that don't explicitly use it themselves.
datefudge Lets you fake the system time and date.
libeatmydata Overridessync()
and related calls to do nothing, improving performance of some applications at the cost of data safety.
dante Includes a command that uses LD_PRELOAD to enable SOCKS protocol usage for applications which don't natively support it.
There's also a library that does exactly what you're asking about called libtrash
. The official web-page can be found here. I'm not sure if it works or not as I've never used it myself, but there was a recent release of a new version so it looks like the author is at least still maintaining it.
Yes, there is. The general mechanism for this type of thing (overriding a standard function) is called LD_PRELOAD. The general idea is pretty simple, when loading libraries into memory for a program, whichever one is the first to define a given symbol name defines what that symbol does. So, LD_PRELOAD lets you tell the dynamic linker to load specific libraries before all others (including libc), meaning that they can override specific functions from libraries which would be loaded later.
Examples of widely used projects that make use of LD_PRELOAD include:
jemalloc Can be pre-loaded to let you use the jemalloc memory allocator with programs that don't explicitly use it themselves.
datefudge Lets you fake the system time and date.
libeatmydata Overridessync()
and related calls to do nothing, improving performance of some applications at the cost of data safety.
dante Includes a command that uses LD_PRELOAD to enable SOCKS protocol usage for applications which don't natively support it.
There's also a library that does exactly what you're asking about called libtrash
. The official web-page can be found here. I'm not sure if it works or not as I've never used it myself, but there was a recent release of a new version so it looks like the author is at least still maintaining it.
answered 22 hours ago
Austin Hemmelgarn
5,59311016
5,59311016
add a comment |
add a comment |
Stuperfied is a new contributor. Be nice, and check out our Code of Conduct.
Stuperfied is a new contributor. Be nice, and check out our Code of Conduct.
Stuperfied is a new contributor. Be nice, and check out our Code of Conduct.
Stuperfied is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482079%2fis-it-possible-to-intercept-calls-to-unlink-and-redirect-files-to-trash%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown