diff --git a/include/attach.h b/include/attach.h new file mode 100644 index 0000000..513b71e --- /dev/null +++ b/include/attach.h @@ -0,0 +1,26 @@ +/* + * attach.h - Core mechanix behind attachment replacing + * The author licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef ATTACH_H +#define ATTACH_H + +#include + +char* attach_files(const unsigned char* original_message, + size_t original_length); + +#endif /* ATTACH_H */ diff --git a/include/detect.h b/include/detect.h index cd09a3e..bdb9a88 100644 --- a/include/detect.h +++ b/include/detect.h @@ -1,5 +1,5 @@ /* - * detect.h - Licensed + * detect.h - Content detection * The author licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance @@ -20,6 +20,6 @@ #include -bool detect_pgp(const FILE* message); +bool detect_pgp(const char* message); #endif /* DETECT_H */ diff --git a/src/attach.c b/src/attach.c new file mode 100644 index 0000000..cd23083 --- /dev/null +++ b/src/attach.c @@ -0,0 +1,32 @@ +/* + * attach.c - Core mechanix behind attachment replacing + * I know how mechanics is spelt, let me have my fun :D + * The author licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include + +char* attach_files(const unsigned char* original_message, + size_t original_length){ + + const char* new_body = malloc(original_length + 1); + if(new_body == NULL){ + return NULL; + } + memset(new_body,0, original_length + 1); + +} + diff --git a/src/config.c b/src/config.c index 1577ad9..18a756d 100644 --- a/src/config.c +++ b/src/config.c @@ -1,5 +1,5 @@ /* - * config.h - Configuration loading and data storage + * config.c - Configuration loading and data storage * The author licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance diff --git a/src/detect.c b/src/detect.c new file mode 100644 index 0000000..9b659d1 --- /dev/null +++ b/src/detect.c @@ -0,0 +1,24 @@ +/* + * detect.c - Detect content + * The author licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "detect.h" + +bool detect_pgp(const char* message){ + + return false; +} + diff --git a/src/main.c b/src/main.c index 9698ad2..15690ae 100644 --- a/src/main.c +++ b/src/main.c @@ -19,7 +19,7 @@ #include "version.h" #include "config.h" -#include "detect.h" +#include "attach.h" struct mlfiPriv { @@ -126,7 +126,17 @@ sfsistat mlfi_body(SMFICTX* ctx, unsigned char * bodyp, size_t bodylen) { (void) mlfi_cleanup(ctx, false); return SMFIS_TEMPFAIL; } - + char* new_body = attach_files(bodyp, bodylen); + if(new_body != NULL){ + + size_t new_bodylen = strlen(new_body)+1; + unsigned char * replacement = malloc(new_bodylen+1); + memset(replacement, 0, new_bodylen+1); + memcpy(replacement, replacement, new_bodylen+1); + free(new_body); + printf("Replacing body of mail message\n"); + smfi_replacebody(ctx, replacement, new_bodylen); + } /* continue processing */ return SMFIS_CONTINUE; }